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: docker-for-mac/index.md
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,9 +126,10 @@ Run these commands to test if your versions of `docker`, `docker-compose`, and `
126
126
127
127
1. Open a command-line terminal, and run some Docker commands to verify that Docker is working as expected.
128
128
129
-
Some good commands to try are `docker version` to check that you have the latest release installed, and `docker ps` and `docker run hello-world` to verify that Docker is running.
129
+
Some good commands to try are `docker version` to check that you have the latest release installed, and `docker run hello-world` to verify that Docker is running. The `hello-world` container runs in the foreground. When it finishes, it stops automatically.
130
130
131
-
2. For something more adventurous, start a Dockerized web server.
131
+
2. For something more adventurous, start a Dockerized web server. This starts a container that
132
+
keeps running in the background until you stop it.
132
133
133
134
```shell
134
135
docker run -d -p 80:80 --name webserver nginx
@@ -142,11 +143,31 @@ Run these commands to test if your versions of `docker`, `docker-compose`, and `
142
143
143
144
>**Note**: Early beta releases used `docker` as the hostname to build the URL. Now, ports are exposed on the private IP addresses of the VM and forwarded to `localhost` with no other host name set. See also, [Release Notes](release-notes.md) for Beta 9.
144
145
145
-
3. Run `docker ps` while your web server is running to see details on the webserver container.
146
+
3. Run `docker ps` to see details on the webserver container and any other running containers. To see
147
+
stopped containers as well, use `docker ps -a`. To see only stopped containers, use `docker ps -f "status=exited"`.
146
148
147
149
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
148
150
56f433965490 nginx "nginx -g 'daemon off" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 443/tcp webserver
149
151
152
+
4. To stop a container which runs in the background, use `docker stop <container_id>` or `docker stop <name>`, after finding the container using the `docker ps` command.
153
+
154
+
```shell
155
+
docker stop 56f433965490
156
+
```
157
+
158
+
5. To start or restart a container which you have started and stopped before, use the command
159
+
`docker start <name>`.
160
+
161
+
```shell
162
+
docker start webserver
163
+
```
164
+
165
+
6. To completely remove a stopped container, use the `docker rm <container_id>` or
166
+
`docker rm <name>` command.
167
+
168
+
```shell
169
+
docker rm webserver
170
+
```
150
171
**Want more example applictions?** - For more example walkthroughs that include setting up services and databases in Docker Compose, see [Example Applications](examples.md).
0 commit comments