Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e27424b

Browse files
johndmulhausenjohndmulhausen
authored andcommitted
2 parents c656382 + 5e8c369 commit e27424b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

docker-for-mac/index.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ Run these commands to test if your versions of `docker`, `docker-compose`, and `
126126

127127
1. Open a command-line terminal, and run some Docker commands to verify that Docker is working as expected.
128128

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.
130130

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.
132133

133134
```shell
134135
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 `
142143

143144
>**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.
144145

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"`.
146148

147149
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
148150
56f433965490 nginx "nginx -g 'daemon off" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 443/tcp webserver
149151

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+
```
150171
**Want more example applictions?** - For more example walkthroughs that include setting up services and databases in Docker Compose, see [Example Applications](examples.md).
151172

152173
## Preferences

0 commit comments

Comments
 (0)