Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ditch a lot of "--link" examples (using "--network some-network" instead to force users to do more homework) #1441

Merged
merged 2 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions cassandra/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,17 @@ Apache Cassandra is an open source distributed database management system design
Starting a Cassandra instance is simple:

```console
$ docker run --name some-%%REPO%% -d %%IMAGE%%:tag
$ docker run --name some-%%REPO%% --network some-network -d %%IMAGE%%:tag
```

tianon marked this conversation as resolved.
Show resolved Hide resolved
... where `some-%%REPO%%` is the name you want to assign to your container and `tag` is the tag specifying the Cassandra version you want. See the list above for relevant tags.

## Connect to Cassandra from an application in another Docker container

This image exposes the standard Cassandra ports (see the [Cassandra FAQ](https://wiki.apache.org/cassandra/FAQ#ports)), so container linking makes the Cassandra instance available to other application containers. Start your application container like this in order to link it to the Cassandra container:

```console
$ docker run --name some-app --link some-%%REPO%%:%%REPO%% -d app-that-uses-cassandra
```

## Make a cluster

Using the environment variables documented below, there are two cluster scenarios: instances on the same machine and instances on separate machines. For the same machine, start the instance as described above. To start other instances, just tell each new node where the first is.

```console
$ docker run --name some-%%REPO%%2 -d -e CASSANDRA_SEEDS="$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' some-%%REPO%%)" %%IMAGE%%:tag
```

... where `some-%%REPO%%` is the name of your original Cassandra Server container, taking advantage of `docker inspect` to get the IP address of the other container.

Or you may use the docker run --link option to tell the new node where the first is:

```console
$ docker run --name some-cassandra2 -d --link some-cassandra:cassandra %%IMAGE%%:tag
$ docker run --name some-%%REPO%%2 -d --network some-network -e CASSANDRA_SEEDS=some-%%REPO%% %%IMAGE%%:tag
```

For separate machines (ie, two VMs on a cloud provider), you need to tell Cassandra what IP address to advertise to the other nodes (since the address of the container is behind the docker bridge).
Expand All @@ -61,17 +45,9 @@ $ docker run --name some-%%REPO%% -d -e CASSANDRA_BROADCAST_ADDRESS=10.43.43.43
The following command starts another Cassandra container instance and runs `cqlsh` (Cassandra Query Language Shell) against your original Cassandra container, allowing you to execute CQL statements against your database instance:

```console
$ docker run -it --link some-%%REPO%%:cassandra --rm %%IMAGE%% sh -c 'exec cqlsh "$CASSANDRA_PORT_9042_TCP_ADDR"'
$ docker run -it --network some-network --rm %%IMAGE%% cqlsh some-%%REPO%%
```

... or (simplified to take advantage of the `/etc/hosts` entry Docker adds for linked containers):

```console
$ docker run -it --link some-%%REPO%%:cassandra --rm %%IMAGE%% cqlsh cassandra
```

... where `some-%%REPO%%` is the name of your original Cassandra Server container.

More information about the CQL can be found in the [Cassandra documentation](https://cassandra.apache.org/doc/latest/cql/index.html).

## Container shell access and viewing Cassandra logs
Expand Down
14 changes: 7 additions & 7 deletions drupal/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ $ docker run --name some-%%REPO%% -p 8080:80 -d %%IMAGE%%

Then, access it via `http://localhost:8080` or `http://host-ip:8080` in a browser.

There are multiple database types supported by this image, most easily used via standard container linking. In the default configuration, SQLite can be used to avoid a second container and write to flat-files. More detailed instructions for different (more production-ready) database types follow.
There are multiple database types supported by this image, most easily used via Docker networks. In the default configuration, SQLite can be used to avoid a second container and write to flat-files. More detailed instructions for different (more production-ready) database types follow.

When first accessing the webserver provided by this image, it will go through a brief setup process. The details provided below are specifically for the "Set up database" step of that configuration process.

## MySQL

```console
$ docker run --name some-%%REPO%% --link some-mysql:mysql -d %%IMAGE%%
$ docker run --name some-%%REPO%% --network some-network -d %%IMAGE%%
```

- Database type: `MySQL, MariaDB, or equivalent`
- Database name/username/password: `<details for accessing your MySQL instance>` (`MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_DATABASE`; see environment variables in the description for [`mysql`](https://hub.docker.com/_/mysql/))
- ADVANCED OPTIONS; Database host: `mysql` (for using the `/etc/hosts` entry added by `--link` to access the linked container's MySQL instance)
- ADVANCED OPTIONS; Database host: `some-mysql` (for using the DNS entry added by `--network` to access the MySQL container)

## PostgreSQL

```console
$ docker run --name some-%%REPO%% --link some-postgres:postgres -d %%IMAGE%%
$ docker run --name some-%%REPO%% --network some-network -d %%IMAGE%%
```

- Database type: `PostgreSQL`
- Database name/username/password: `<details for accessing your PostgreSQL instance>` (`POSTGRES_USER`, `POSTGRES_PASSWORD`; see environment variables in the description for [`postgres`](https://hub.docker.com/_/postgres/))
- ADVANCED OPTIONS; Database host: `postgres` (for using the `/etc/hosts` entry added by `--link` to access the linked container's PostgreSQL instance)
- ADVANCED OPTIONS; Database host: `some-postgres` (for using the DNS entry added by `--network` to access the PostgreSQL container)

## Volumes

Expand All @@ -61,7 +61,7 @@ $ docker run --rm %%IMAGE%% tar -cC /var/www/html/sites . | tar -xC /path/on/hos
This can then be bind-mounted into a new container:

```console
$ docker run --name some-%%REPO%% --link some-postgres:postgres -d \
$ docker run --name some-%%REPO%% --network some-network -d \
-v /path/on/host/modules:/var/www/html/modules \
-v /path/on/host/profiles:/var/www/html/profiles \
-v /path/on/host/sites:/var/www/html/sites \
Expand All @@ -74,7 +74,7 @@ Another solution using Docker Volumes:
```console
$ docker volume create %%REPO%%-sites
$ docker run --rm -v %%REPO%%-sites:/temporary/sites %%IMAGE%% cp -aRT /var/www/html/sites /temporary/sites
$ docker run --name some-%%REPO%% --link some-postgres:postgres -d \
$ docker run --name some-%%REPO%% --network some-network -d \
-v %%REPO%%-modules:/var/www/html/modules \
-v %%REPO%%-profiles:/var/www/html/profiles \
-v %%REPO%%-sites:/var/www/html/sites \
Expand Down
20 changes: 5 additions & 15 deletions mariadb/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,17 @@ $ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE

... where `some-%%REPO%%` is the name you want to assign to your container, `my-secret-pw` is the password to be set for the MySQL root user and `tag` is the tag specifying the MySQL version you want. See the list above for relevant tags.

## Connect to MySQL from an application in another Docker container

Since MariaDB is intended as a drop-in replacement for MySQL, it can be used with many applications.

This image exposes the standard MySQL port (3306), so container linking makes the MySQL instance available to other application containers. Start your application container like this in order to link it to the MySQL container:

```console
$ docker run --name some-app --link some-%%REPO%%:mysql -d application-that-uses-mysql
```

## Connect to MariaDB from the MySQL command line client

The following command starts another `%%IMAGE%%` container instance and runs the `mysql` command line client against your original `%%IMAGE%%` container, allowing you to execute SQL statements against your database instance:

```console
$ docker run -it --link some-%%REPO%%:mysql --rm %%IMAGE%% sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
$ docker run -it --network some-network --rm %%IMAGE%% mysql -hsome-%%REPO%% -uexample-user -p
```

... where `some-%%REPO%%` is the name of your original `%%IMAGE%%` container.
... where `some-%%REPO%%` is the name of your original `%%IMAGE%%` container (connected to the `some-network` Docker network).

This image can also be used as a client for non-Docker or remote MariaDB instances:
This image can also be used as a client for non-Docker or remote instances:

```console
$ docker run -it --rm %%IMAGE%% mysql -hsome.mysql.host -usome-mysql-user -p
Expand All @@ -60,15 +50,15 @@ The `docker exec` command allows you to run commands inside a Docker container.
$ docker exec -it some-%%REPO%% bash
```

The MariaDB Server log is available through Docker's container log:
The log is available through Docker's container log:

```console
$ docker logs some-%%REPO%%
```

## Using a custom MySQL configuration file

The MariaDB startup configuration is specified in the file `/etc/mysql/my.cnf`, and that file in turn includes any files found in the `/etc/mysql/conf.d` directory that end with `.cnf`. Settings in files in this directory will augment and/or override settings in `/etc/mysql/my.cnf`. If you want to use a customized MySQL configuration, you can create your alternative configuration file in a directory on the host machine and then mount that directory location as `/etc/mysql/conf.d` inside the `%%IMAGE%%` container.
The startup configuration is specified in the file `/etc/mysql/my.cnf`, and that file in turn includes any files found in the `/etc/mysql/conf.d` directory that end with `.cnf`. Settings in files in this directory will augment and/or override settings in `/etc/mysql/my.cnf`. If you want to use a customized MySQL configuration, you can create your alternative configuration file in a directory on the host machine and then mount that directory location as `/etc/mysql/conf.d` inside the `%%IMAGE%%` container.

If `/my/custom/config-file.cnf` is the path and name of your custom configuration file, you can start your `%%IMAGE%%` container like this (note that only the directory path of the custom config file is used in this command):

Expand Down
12 changes: 2 additions & 10 deletions memcached/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,12 @@ Memcached's APIs provide a very large hash table distributed across multiple mac
$ docker run --name my-memcache -d %%IMAGE%%
```

Start your memcached container with the above command and then you can connect you app to it with standard linking:

```console
$ docker run --link my-memcache:memcache -d my-app-image
```

The memcached server information would then be available through the ENV variables generated by the link as well as through DNS as `memcache` from `/etc/hosts`.

How to set the memory usage for memcached
## Setting Memory Usage

```console
$ docker run --name my-memcache -d %%IMAGE%% memcached -m 64
```

This would set the memcache server to use 64 megabytes for storage.
This would set the Memcached server to use 64 megabytes for storage.

For infomation on configuring your memcached server, see the extensive [wiki](https://github.com/memcached/memcached/wiki).
5 changes: 3 additions & 2 deletions mongo-express/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mongo-express is a web-based MongoDB admin interface written in Node.js, Express
# How to use this image

```console
$ docker run --link some_mongo_container:mongo -p 8081:8081 %%IMAGE%%
$ docker run --network some-network -e ME_CONFIG_MONGODB_SERVER=some-mongo -p 8081:8081 %%IMAGE%%
```

Then you can hit `http://localhost:8081` or `http://host-ip:8081` in your browser.
Expand Down Expand Up @@ -54,10 +54,11 @@ The following are only needed if `ME_CONFIG_MONGODB_ENABLE_ADMIN` is **"false"**

```console
$ docker run -it --rm \
--network web_default \
--name mongo-express \
--link web_db_1:mongo \
-p 8081:8081 \
-e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" \
-e ME_CONFIG_MONGODB_SERVER="web_db_1" \
-e ME_CONFIG_BASICAUTH_USERNAME="user" \
-e ME_CONFIG_BASICAUTH_PASSWORD="fairly long password" \
%%IMAGE%%
Expand Down
10 changes: 5 additions & 5 deletions mongo/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ $ docker run --name some-%%REPO%% -d %%IMAGE%%:tag

## Connect to MongoDB from another Docker container

The MongoDB server in the image listens on the standard MongoDB port, `27017`, so connecting via container linking or Docker networks will be the same as connecting to a remote `mongod`. The following example starts another MongoDB container instance and runs the `mongo` command line client against the original MongoDB container from the example above, allowing you to execute MongoDB statements against your database instance:
The MongoDB server in the image listens on the standard MongoDB port, `27017`, so connecting via Docker networks will be the same as connecting to a remote `mongod`. The following example starts another MongoDB container instance and runs the `mongo` command line client against the original MongoDB container from the example above, allowing you to execute MongoDB statements against your database instance:

```console
$ docker run -it --link some-%%REPO%%:mongo --rm %%IMAGE%% mongo --host mongo test
$ docker run -it --network some-network --rm %%IMAGE%% mongo --host some-%%REPO%% test
```

... where `some-%%REPO%%` is the name of your original `mongo` container.
Expand Down Expand Up @@ -107,13 +107,13 @@ These variables, used in conjunction, create a new user and set that user's pass
The following is an example of using these two variables to create a MongoDB instance and then using the `mongo` cli to connect against the `admin` authentication database.

```console
$ docker run -d --name some-%%REPO%% \
$ docker run -d --network some-network --name some-%%REPO%% \
-e MONGO_INITDB_ROOT_USERNAME=mongoadmin \
-e MONGO_INITDB_ROOT_PASSWORD=secret \
%%IMAGE%%

$ docker run -it --rm --link some-%%REPO%%:mongo %%IMAGE%% \
mongo --host mongo \
$ docker run -it --rm --network some-network %%IMAGE%% \
mongo --host some-mongo \
-u mongoadmin \
-p secret \
--authenticationDatabase admin \
Expand Down
16 changes: 4 additions & 12 deletions mysql/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,17 @@ $ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE

... where `some-%%REPO%%` is the name you want to assign to your container, `my-secret-pw` is the password to be set for the MySQL root user and `tag` is the tag specifying the MySQL version you want. See the list above for relevant tags.

## Connect to MySQL from an application in another Docker container

This image exposes the standard MySQL port (3306), so container linking makes the MySQL instance available to other application containers. Start your application container like this in order to link it to the MySQL container:

```console
$ docker run --name some-app --link some-%%REPO%%:mysql -d application-that-uses-mysql
```

## Connect to MySQL from the MySQL command line client

The following command starts another `%%IMAGE%%` container instance and runs the `mysql` command line client against your original `%%IMAGE%%` container, allowing you to execute SQL statements against your database instance:

```console
$ docker run -it --link some-%%REPO%%:mysql --rm %%IMAGE%% sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
$ docker run -it --network some-network --rm %%IMAGE%% mysql -hsome-%%REPO%% -uexample-user -p
```

... where `some-%%REPO%%` is the name of your original `%%IMAGE%%` container.
... where `some-%%REPO%%` is the name of your original `%%IMAGE%%` container (connected to the `some-network` Docker network).

This image can also be used as a client for non-Docker or remote MySQL instances:
This image can also be used as a client for non-Docker or remote instances:

```console
$ docker run -it --rm %%IMAGE%% mysql -hsome.mysql.host -usome-mysql-user -p
Expand All @@ -56,7 +48,7 @@ The `docker exec` command allows you to run commands inside a Docker container.
$ docker exec -it some-%%REPO%% bash
```

The MySQL Server log is available through Docker's container log:
The log is available through Docker's container log:

```console
$ docker logs some-%%REPO%%
Expand Down
16 changes: 3 additions & 13 deletions percona/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,15 @@ $ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE

... where `some-%%REPO%%` is the name you want to assign to your container, `my-secret-pw` is the password to be set for the MySQL root user and `tag` is the tag specifying the MySQL version you want. See the list above for relevant tags.

## Connect to MySQL from an application in another Docker container

Since Percona Server for MySQL is intended as a drop-in replacement for MySQL, it can be used with many applications.

This image exposes the standard MySQL port (3306), so container linking makes the MySQL instance available to other application containers. Start your application container like this in order to link it to the MySQL container:

```console
$ docker run --name some-app --link some-%%REPO%%:mysql -d application-that-uses-mysql
```

## Connect to Percona Server for MySQL from the command line client
## Connect to MariaDB from the MySQL command line client

The following command starts another `%%IMAGE%%` container instance and runs the `mysql` command line client against your original `%%IMAGE%%` container, allowing you to execute SQL statements against your database instance:

```console
$ docker run -it --link some-%%REPO%%:mysql --rm %%IMAGE%% sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
$ docker run -it --network some-network --rm %%IMAGE%% mysql -hsome-%%REPO%% -uexample-user -p
```

... where `some-%%REPO%%` is the name of your original `%%IMAGE%%` container.
... where `some-%%REPO%%` is the name of your original `%%IMAGE%%` container (connected to the `some-network` Docker network).

This image can also be used as a client for non-Docker or remote instances:

Expand Down
8 changes: 1 addition & 7 deletions postgres/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,10 @@ The default `postgres` user and database are created in the entrypoint with `ini
>
> [postgresql.org/docs](http://www.postgresql.org/docs/9.5/interactive/app-initdb.html)

## connect to it from an application

```console
$ docker run --name some-app --link some-postgres:postgres -d application-that-uses-postgres
```

## ... or via `psql`

```console
$ docker run -it --rm --link some-postgres:postgres %%IMAGE%% psql -h postgres -U postgres
$ docker run -it --rm --network some-network %%IMAGE%% psql -h some-postgres -U postgres
psql (9.5.0)
Type "help" for help.

Expand Down
Loading