engine/examples: fix up some markdown

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-04-12 18:46:03 +02:00
parent cb4a1293a7
commit e1d27921c3
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
3 changed files with 139 additions and 92 deletions

View File

@ -16,6 +16,7 @@ the second download of any package almost instant.
Use the following Dockerfile:
```dockerfile
#
# Build: docker build -t apt-cacher .
# Run: docker run -d -p 3142:3142 --name apt-cacher-run apt-cacher
@ -32,19 +33,26 @@ Use the following Dockerfile:
EXPOSE 3142
CMD chmod 777 /var/cache/apt-cacher-ng && /etc/init.d/apt-cacher-ng start && tail -f /var/log/apt-cacher-ng/*
```
To build the image using:
```bash
$ docker build -t eg_apt_cacher_ng .
```
Then run it, mapping the exposed port to one on the host
```bash
$ docker run -d -p 3142:3142 --name test_apt_cacher_ng eg_apt_cacher_ng
```
To see the logfiles that are `tailed` in the default command, you can
use:
```bash
$ docker logs -f test_apt_cacher_ng
```
To get your Debian-based containers to use the proxy, you have
following options. Replace `dockerhost` with the
@ -63,34 +71,43 @@ container.
**Option 1** injects the settings safely into your apt configuration in
a local version of a common base:
```dockerfile
FROM ubuntu
RUN echo 'Acquire::http { Proxy "http://dockerhost:3142"; };' >> /etc/apt/apt.conf.d/01proxy
RUN apt-get update && apt-get install -y vim git
# docker build -t my_ubuntu .
```
**Option 2** is good for testing, but breaks other HTTP clients
which obey `http_proxy`, such as `curl`, `wget` and others:
```bash
$ docker run --rm -t -i -e http_proxy=http://dockerhost:3142/ debian bash
```
**Option 3** is the least portable, but you might need to do it and you can do it
from your `Dockerfile` too.
**Option 4** links Debian-containers to the proxy server using following command:
```bash
$ docker run -i -t --link test_apt_cacher_ng:apt_proxy -e http_proxy=http://apt_proxy:3142/ debian bash
```
**Option 5** creates a custom network of APT proxy server and Debian-based containers:
```bash
$ docker network create mynetwork
$ docker run -d -p 3142:3142 --network=mynetwork --name test_apt_cacher_ng eg_apt_cacher_ng
$ docker run --rm -it --network=mynetwork -e http_proxy=http://test_apt_cacher_ng:3142/ debian bash
```
Apt-cacher-ng has some tools that allow you to manage the repository,
and they can be used by leveraging the `VOLUME`
instruction, and the image we built to run the service:
```bash
$ docker run --rm -t -i --volumes-from test_apt_cacher_ng eg_apt_cacher_ng bash
root@f38c87f2a42d:/# /usr/lib/apt-cacher-ng/distkill.pl
@ -111,10 +128,13 @@ instruction, and the image we built to run the service:
index files. Select d to see detailed list.
(Number nn: tag distribution or architecture nn; 0: exit; d: show details; r: remove tagged; q: quit): q
```
Finally, clean up after your test by stopping and removing the
container, and then removing the image.
```bash
$ docker container stop test_apt_cacher_ng
$ docker container rm test_apt_cacher_ng
$ docker image rm eg_apt_cacher_ng
```

View File

@ -4,8 +4,9 @@ keywords: docker, example, package installation, networking, couchdb, data volu
title: Dockerize a CouchDB service
---
> **Note**:
> - **If you don't like sudo** then see [*Giving non-root access*](../install/linux-postinstall.md#manage-docker-as-a-non-root-user)
> **Note**
>
> **If you don't like sudo** then see [*Giving non-root access*](../install/linux-postinstall.md#manage-docker-as-a-non-root-user)
Here's an example of using data volumes to share the same data between
two CouchDB containers. This could be used for hot upgrades, testing
@ -15,28 +16,36 @@ different versions of CouchDB on the same data, etc.
We're marking `/var/lib/couchdb` as a data volume.
```bash
$ COUCH1=$(docker run -d -p 5984 -v /var/lib/couchdb shykes/couchdb:2013-05-03)
```
## Add data to the first database
We're assuming your Docker host is reachable at `localhost`. If not,
replace `localhost` with the public IP of your Docker host.
```bash
$ HOST=localhost
$ URL="http://$HOST:$(docker port $COUCH1 5984 | grep -o '[1-9][0-9]*$')/_utils/"
$ echo "Navigate to $URL in your browser, and use the couch interface to add data"
```
## Create second database
This time, we're requesting shared access to `$COUCH1`'s volumes.
```bash
$ COUCH2=$(docker run -d -p 5984 --volumes-from $COUCH1 shykes/couchdb:2013-05-03)
```
## Browse data on the second database
```bash
$ HOST=localhost
$ URL="http://$HOST:$(docker port $COUCH2 5984 | grep -o '[1-9][0-9]*$')/_utils/"
$ echo "Navigate to $URL in your browser. You should see the same data as in the first database"'!'
```
Congratulations, you are now running two Couchdb containers, completely
isolated from each other *except* for their data.

View File

@ -11,34 +11,39 @@ Riak pre-installed.
Create an empty file called `Dockerfile`:
```bash
$ touch Dockerfile
```
Next, define the parent image you want to use to build your image on top
of. We use [Ubuntu](https://hub.docker.com/_/ubuntu/) (tag:
`trusty`), which is available on [Docker Hub](https://hub.docker.com):
```dockerfile
# Riak
#
# VERSION 0.1.1
# Use the Ubuntu parent image provided by dotCloud
FROM ubuntu:trusty
```
After that, we install the curl which is used to download the repository setup
script and we download the setup script and run it.
```dockerfile
# Install Riak repository before we do apt-get update, so that update happens
# in a single step
RUN apt-get install -q -y curl && \
curl -fsSL https://packagecloud.io/install/repositories/basho/riak/script.deb | sudo bash
```
Then we install and setup a few dependencies:
- `supervisor` is used manage the Riak processes
- `riak=2.0.5-1` is the Riak package coded to version 2.0.5
<!-- -->
```dockerfile
# Install and setup project dependencies
RUN apt-get update && \
apt-get install -y supervisor riak=2.0.5-1
@ -48,31 +53,41 @@ Then we install and setup a few dependencies:
RUN locale-gen en_US en_US.UTF-8
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
```
After that, we modify Riak's configuration:
```dockerfile
# Configure Riak to accept connections from any host
RUN sed -i "s|listener.http.internal = 127.0.0.1:8098|listener.http.internal = 0.0.0.0:8098|" /etc/riak/riak.conf
RUN sed -i "s|listener.protobuf.internal = 127.0.0.1:8087|listener.protobuf.internal = 0.0.0.0:8087|" /etc/riak/riak.conf
```
Then, we expose the Riak Protocol Buffers and HTTP interfaces:
```dockerfile
# Expose Riak Protocol Buffers and HTTP interfaces
EXPOSE 8087 8098
```
Finally, run `supervisord` so that Riak is started:
```dockerfile
CMD ["/usr/bin/supervisord"]
```
## Create a supervisord configuration file
Create an empty file called `supervisord.conf`. Make
sure it's at the same directory level as your `Dockerfile`:
```bash
touch supervisord.conf
```
Populate it with the following program definitions:
```ini
[supervisord]
nodaemon=true
@ -85,12 +100,15 @@ Populate it with the following program definitions:
environment=HOME="/var/lib/riak"
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
```
## Build the Docker image for Riak
Now you can build a Docker image for Riak:
```bash
$ docker build -t "<yourname>/riak" .
```
## Next steps