You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: compose/environment-variables.md
+2-4
Original file line number
Diff line number
Diff line change
@@ -50,11 +50,11 @@ You can pass multiple environment variables from an external file through to a s
50
50
51
51
Just like with `docker run -e`, you can set environment variables on a one-off container with `docker-compose run -e`:
52
52
53
-
$ docker-compose run -e DEBUG=1 web python console.py
53
+
docker-compose run -e DEBUG=1 web python console.py
54
54
55
55
You can also pass a variable through from the shell by not giving it a value:
56
56
57
-
$ docker-compose run -e DEBUG web python console.py
57
+
docker-compose run -e DEBUG web python console.py
58
58
59
59
The value of the `DEBUG` variable in the container will be taken from the value for the same variable in the shell in which Compose is run.
60
60
@@ -83,7 +83,6 @@ When you run `docker-compose up`, the `web` service defined above uses the image
83
83
Values in the shell take precedence over those specified in the `.env` file. If you set `TAG` to a different value in your shell, the substitution in `image` uses that instead:
84
84
85
85
$ export TAG=v2.0
86
-
87
86
$ docker-compose config
88
87
version: '2.0'
89
88
services:
@@ -94,7 +93,6 @@ Values in the shell take precedence over those specified in the `.env` file. If
94
93
95
94
Several environment variables are available for you to configure the Docker Compose command-line behaviour. They begin with `COMPOSE_` or `DOCKER_`, and are documented in [CLI Environment Variables](reference/envvars.md).
96
95
97
-
98
96
## Environment variables created by links
99
97
100
98
When using the ['links' option](compose-file.md#links) in a [v1 Compose file](compose-file.md#version-1), environment variables will be created for each link. They are documented in the [Link environment variables reference](link-env-deprecated.md). Please note, however, that these variables are deprecated - you should just use the link alias as a hostname instead.
Copy file name to clipboardexpand all lines: compose/gettingstarted.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -163,14 +163,14 @@ The `docker-compose run` command allows you to run one-off commands for your
163
163
services. For example, to see what environment variables are available to the
164
164
`web` service:
165
165
166
-
$ docker-compose run web env
166
+
docker-compose run web env
167
167
168
168
See `docker-compose --help` to see other available commands. You can also install [command completion](completion.md) for the bash and zsh shell, which will also show you available commands.
169
169
170
170
If you started Compose with `docker-compose up -d`, you'll probably want to stop
171
171
your services once you've finished with them:
172
172
173
-
$ docker-compose stop
173
+
docker-compose stop
174
174
175
175
At this point, you have seen the basics of how Compose works.
Copy file name to clipboardexpand all lines: compose/rails.md
+5-6
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ Next, create a bootstrap `Gemfile` which just loads Rails. It'll be overwritten
34
34
35
35
You'll need an empty `Gemfile.lock` in order to build our `Dockerfile`.
36
36
37
-
$ touch Gemfile.lock
37
+
touch Gemfile.lock
38
38
39
39
Finally, `docker-compose.yml` is where the magic happens. This file describes
40
40
the services that comprise your app (a database and a web app), how to get each
@@ -61,7 +61,7 @@ to link them together and expose the web app's port.
61
61
With those three files in place, you can now generate the Rails skeleton app
62
62
using `docker-compose run`:
63
63
64
-
$ docker-compose run web rails new . --force --database=postgresql --skip-bundle
64
+
docker-compose run web rails new . --force --database=postgresql --skip-bundle
65
65
66
66
First, Compose will build the image for the `web` service using the `Dockerfile`. Then it'll run `rails new` inside a new container, using that image. Once it's done, you should have generated a fresh app:
67
67
@@ -105,8 +105,7 @@ Now that you've got a new `Gemfile`, you need to build the image again. (This,
105
105
and changes to the Dockerfile itself, should be the only times you'll need to
106
106
rebuild.)
107
107
108
-
$ docker-compose build
109
-
108
+
docker-compose build
110
109
111
110
### Connect the database
112
111
@@ -132,7 +131,7 @@ Replace the contents of `config/database.yml` with the following:
132
131
133
132
You can now boot the app with:
134
133
135
-
$ docker-compose up
134
+
docker-compose up
136
135
137
136
If all's well, you should see some PostgreSQL output, and then—after a few
138
137
seconds—the familiar refrain:
@@ -143,7 +142,7 @@ seconds—the familiar refrain:
143
142
144
143
Finally, you need to create the database. In another terminal, run:
145
144
146
-
$ docker-compose run web rake db:create
145
+
docker-compose run web rake db:create
147
146
148
147
That's it. Your app should now be running on port 3000 on your Docker daemon. If you're using [Docker Machine](/machine/overview.md), then `docker-machine ip MACHINE_VM` returns the Docker host IP address.
Copy file name to clipboardexpand all lines: compose/reference/run.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -24,26 +24,26 @@ Options:
24
24
25
25
Runs a one-time command against a service. For example, the following command starts the `web` service and runs `bash` as its command.
26
26
27
-
$ docker-compose run web bash
27
+
docker-compose run web bash
28
28
29
29
Commands you use with `run` start in new containers with the same configuration as defined by the service' configuration. This means the container has the same volumes, links, as defined in the configuration file. There two differences though.
30
30
31
31
First, the command passed by `run` overrides the command defined in the service configuration. For example, if the `web` service configuration is started with `bash`, then `docker-compose run web python app.py` overrides it with `python app.py`.
32
32
33
33
The second difference is the `docker-compose run` command does not create any of the ports specified in the service configuration. This prevents the port collisions with already open ports. If you *do want* the service's ports created and mapped to the host, specify the `--service-ports` flag:
34
34
35
-
$ docker-compose run --service-ports web python manage.py shell
35
+
docker-compose run --service-ports web python manage.py shell
36
36
37
37
Alternatively manual port mapping can be specified. Same as when running Docker's `run` command - using `--publish` or `-p` options:
38
38
39
-
$ docker-compose run --publish 8080:80 -p 2022:22 -p 127.0.0.1:2021:21 web python manage.py shell
39
+
docker-compose run --publish 8080:80 -p 2022:22 -p 127.0.0.1:2021:21 web python manage.py shell
40
40
41
41
If you start a service configured with links, the `run` command first checks to see if the linked service is running and starts the service if it is stopped. Once all the linked services are running, the `run` executes the command you passed it. So, for example, you could run:
42
42
43
-
$ docker-compose run db psql -h db -U docker
43
+
docker-compose run db psql -h db -U docker
44
44
45
45
This would open up an interactive PostgreSQL shell for the linked `db` container.
46
46
47
47
If you do not want the `run` command to start linked containers, specify the `--no-deps` flag:
48
48
49
-
$ docker-compose run --no-deps web python manage.py shell
49
+
docker-compose run --no-deps web python manage.py shell
0 commit comments