Skip to content

Commit 6523f95

Browse files
authored
Merge pull request #1441 from infosiftr/ditch-lots-of-linking
Ditch a lot of "--link" examples (using "--network some-network" instead to force users to do more homework)
2 parents 6985f2e + 1da9a5c commit 6523f95

File tree

13 files changed

+53
-130
lines changed

13 files changed

+53
-130
lines changed

cassandra/content.md

+3-27
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,17 @@ Apache Cassandra is an open source distributed database management system design
1313
Starting a Cassandra instance is simple:
1414

1515
```console
16-
$ docker run --name some-%%REPO%% -d %%IMAGE%%:tag
16+
$ docker run --name some-%%REPO%% --network some-network -d %%IMAGE%%:tag
1717
```
1818

1919
... 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.
2020

21-
## Connect to Cassandra from an application in another Docker container
22-
23-
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:
24-
25-
```console
26-
$ docker run --name some-app --link some-%%REPO%%:%%REPO%% -d app-that-uses-cassandra
27-
```
28-
2921
## Make a cluster
3022

3123
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.
3224

3325
```console
34-
$ docker run --name some-%%REPO%%2 -d -e CASSANDRA_SEEDS="$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' some-%%REPO%%)" %%IMAGE%%:tag
35-
```
36-
37-
... 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.
38-
39-
Or you may use the docker run --link option to tell the new node where the first is:
40-
41-
```console
42-
$ docker run --name some-cassandra2 -d --link some-cassandra:cassandra %%IMAGE%%:tag
26+
$ docker run --name some-%%REPO%%2 -d --network some-network -e CASSANDRA_SEEDS=some-%%REPO%% %%IMAGE%%:tag
4327
```
4428

4529
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).
@@ -61,17 +45,9 @@ $ docker run --name some-%%REPO%% -d -e CASSANDRA_BROADCAST_ADDRESS=10.43.43.43
6145
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:
6246

6347
```console
64-
$ docker run -it --link some-%%REPO%%:cassandra --rm %%IMAGE%% sh -c 'exec cqlsh "$CASSANDRA_PORT_9042_TCP_ADDR"'
48+
$ docker run -it --network some-network --rm %%IMAGE%% cqlsh some-%%REPO%%
6549
```
6650

67-
... or (simplified to take advantage of the `/etc/hosts` entry Docker adds for linked containers):
68-
69-
```console
70-
$ docker run -it --link some-%%REPO%%:cassandra --rm %%IMAGE%% cqlsh cassandra
71-
```
72-
73-
... where `some-%%REPO%%` is the name of your original Cassandra Server container.
74-
7551
More information about the CQL can be found in the [Cassandra documentation](https://cassandra.apache.org/doc/latest/cql/index.html).
7652

7753
## Container shell access and viewing Cassandra logs

drupal/content.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,29 @@ $ docker run --name some-%%REPO%% -p 8080:80 -d %%IMAGE%%
2222

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

25-
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.
25+
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.
2626

2727
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.
2828

2929
## MySQL
3030

3131
```console
32-
$ docker run --name some-%%REPO%% --link some-mysql:mysql -d %%IMAGE%%
32+
$ docker run --name some-%%REPO%% --network some-network -d %%IMAGE%%
3333
```
3434

3535
- Database type: `MySQL, MariaDB, or equivalent`
3636
- 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/))
37-
- ADVANCED OPTIONS; Database host: `mysql` (for using the `/etc/hosts` entry added by `--link` to access the linked container's MySQL instance)
37+
- ADVANCED OPTIONS; Database host: `some-mysql` (for using the DNS entry added by `--network` to access the MySQL container)
3838

3939
## PostgreSQL
4040

4141
```console
42-
$ docker run --name some-%%REPO%% --link some-postgres:postgres -d %%IMAGE%%
42+
$ docker run --name some-%%REPO%% --network some-network -d %%IMAGE%%
4343
```
4444

4545
- Database type: `PostgreSQL`
4646
- 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/))
47-
- ADVANCED OPTIONS; Database host: `postgres` (for using the `/etc/hosts` entry added by `--link` to access the linked container's PostgreSQL instance)
47+
- ADVANCED OPTIONS; Database host: `some-postgres` (for using the DNS entry added by `--network` to access the PostgreSQL container)
4848

4949
## Volumes
5050

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

6363
```console
64-
$ docker run --name some-%%REPO%% --link some-postgres:postgres -d \
64+
$ docker run --name some-%%REPO%% --network some-network -d \
6565
-v /path/on/host/modules:/var/www/html/modules \
6666
-v /path/on/host/profiles:/var/www/html/profiles \
6767
-v /path/on/host/sites:/var/www/html/sites \
@@ -74,7 +74,7 @@ Another solution using Docker Volumes:
7474
```console
7575
$ docker volume create %%REPO%%-sites
7676
$ docker run --rm -v %%REPO%%-sites:/temporary/sites %%IMAGE%% cp -aRT /var/www/html/sites /temporary/sites
77-
$ docker run --name some-%%REPO%% --link some-postgres:postgres -d \
77+
$ docker run --name some-%%REPO%% --network some-network -d \
7878
-v %%REPO%%-modules:/var/www/html/modules \
7979
-v %%REPO%%-profiles:/var/www/html/profiles \
8080
-v %%REPO%%-sites:/var/www/html/sites \

mariadb/content.md

+5-15
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,17 @@ $ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE
2020

2121
... 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.
2222

23-
## Connect to MySQL from an application in another Docker container
24-
25-
Since MariaDB is intended as a drop-in replacement for MySQL, it can be used with many applications.
26-
27-
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:
28-
29-
```console
30-
$ docker run --name some-app --link some-%%REPO%%:mysql -d application-that-uses-mysql
31-
```
32-
3323
## Connect to MariaDB from the MySQL command line client
3424

3525
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:
3626

3727
```console
38-
$ 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"'
28+
$ docker run -it --network some-network --rm %%IMAGE%% mysql -hsome-%%REPO%% -uexample-user -p
3929
```
4030

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

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

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

63-
The MariaDB Server log is available through Docker's container log:
53+
The log is available through Docker's container log:
6454

6555
```console
6656
$ docker logs some-%%REPO%%
6757
```
6858

6959
## Using a custom MySQL configuration file
7060

71-
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.
61+
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.
7262

7363
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):
7464

memcached/content.md

+2-10
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,12 @@ Memcached's APIs provide a very large hash table distributed across multiple mac
1212
$ docker run --name my-memcache -d %%IMAGE%%
1313
```
1414

15-
Start your memcached container with the above command and then you can connect you app to it with standard linking:
16-
17-
```console
18-
$ docker run --link my-memcache:memcache -d my-app-image
19-
```
20-
21-
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`.
22-
23-
How to set the memory usage for memcached
15+
## Setting Memory Usage
2416

2517
```console
2618
$ docker run --name my-memcache -d %%IMAGE%% memcached -m 64
2719
```
2820

29-
This would set the memcache server to use 64 megabytes for storage.
21+
This would set the Memcached server to use 64 megabytes for storage.
3022

3123
For infomation on configuring your memcached server, see the extensive [wiki](https://github.com/memcached/memcached/wiki).

mongo-express/content.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mongo-express is a web-based MongoDB admin interface written in Node.js, Express
99
# How to use this image
1010

1111
```console
12-
$ docker run --link some_mongo_container:mongo -p 8081:8081 %%IMAGE%%
12+
$ docker run --network some-network -e ME_CONFIG_MONGODB_SERVER=some-mongo -p 8081:8081 %%IMAGE%%
1313
```
1414

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

5555
```console
5656
$ docker run -it --rm \
57+
--network web_default \
5758
--name mongo-express \
58-
--link web_db_1:mongo \
5959
-p 8081:8081 \
6060
-e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" \
61+
-e ME_CONFIG_MONGODB_SERVER="web_db_1" \
6162
-e ME_CONFIG_BASICAUTH_USERNAME="user" \
6263
-e ME_CONFIG_BASICAUTH_PASSWORD="fairly long password" \
6364
%%IMAGE%%

mongo/content.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ $ docker run --name some-%%REPO%% -d %%IMAGE%%:tag
2020

2121
## Connect to MongoDB from another Docker container
2222

23-
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:
23+
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:
2424

2525
```console
26-
$ docker run -it --link some-%%REPO%%:mongo --rm %%IMAGE%% mongo --host mongo test
26+
$ docker run -it --network some-network --rm %%IMAGE%% mongo --host some-%%REPO%% test
2727
```
2828

2929
... where `some-%%REPO%%` is the name of your original `mongo` container.
@@ -107,13 +107,13 @@ These variables, used in conjunction, create a new user and set that user's pass
107107
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.
108108

109109
```console
110-
$ docker run -d --name some-%%REPO%% \
110+
$ docker run -d --network some-network --name some-%%REPO%% \
111111
-e MONGO_INITDB_ROOT_USERNAME=mongoadmin \
112112
-e MONGO_INITDB_ROOT_PASSWORD=secret \
113113
%%IMAGE%%
114114
115-
$ docker run -it --rm --link some-%%REPO%%:mongo %%IMAGE%% \
116-
mongo --host mongo \
115+
$ docker run -it --rm --network some-network %%IMAGE%% \
116+
mongo --host some-mongo \
117117
-u mongoadmin \
118118
-p secret \
119119
--authenticationDatabase admin \

mysql/content.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,17 @@ $ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE
1818

1919
... 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.
2020

21-
## Connect to MySQL from an application in another Docker container
22-
23-
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:
24-
25-
```console
26-
$ docker run --name some-app --link some-%%REPO%%:mysql -d application-that-uses-mysql
27-
```
28-
2921
## Connect to MySQL from the MySQL command line client
3022

3123
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:
3224

3325
```console
34-
$ 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"'
26+
$ docker run -it --network some-network --rm %%IMAGE%% mysql -hsome-%%REPO%% -uexample-user -p
3527
```
3628

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

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

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

59-
The MySQL Server log is available through Docker's container log:
51+
The log is available through Docker's container log:
6052

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

percona/content.md

+3-13
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,15 @@ $ docker run --name some-%%REPO%% -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%IMAGE
2020

2121
... 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.
2222

23-
## Connect to MySQL from an application in another Docker container
24-
25-
Since Percona Server for MySQL is intended as a drop-in replacement for MySQL, it can be used with many applications.
26-
27-
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:
28-
29-
```console
30-
$ docker run --name some-app --link some-%%REPO%%:mysql -d application-that-uses-mysql
31-
```
32-
33-
## Connect to Percona Server for MySQL from the command line client
23+
## Connect to MariaDB from the MySQL command line client
3424

3525
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:
3626

3727
```console
38-
$ 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"'
28+
$ docker run -it --network some-network --rm %%IMAGE%% mysql -hsome-%%REPO%% -uexample-user -p
3929
```
4030

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

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

postgres/content.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,10 @@ The default `postgres` user and database are created in the entrypoint with `ini
2222
>
2323
> [postgresql.org/docs](http://www.postgresql.org/docs/9.5/interactive/app-initdb.html)
2424
25-
## connect to it from an application
26-
27-
```console
28-
$ docker run --name some-app --link some-postgres:postgres -d application-that-uses-postgres
29-
```
30-
3125
## ... or via `psql`
3226

3327
```console
34-
$ docker run -it --rm --link some-postgres:postgres %%IMAGE%% psql -h postgres -U postgres
28+
$ docker run -it --rm --network some-network %%IMAGE%% psql -h some-postgres -U postgres
3529
psql (9.5.0)
3630
Type "help" for help.
3731

0 commit comments

Comments
 (0)