From 5e8c3691f14769de074ec4de8dfb97f18afda62a Mon Sep 17 00:00:00 2001 From: Misty Stanley-Jones Date: Tue, 23 Aug 2016 14:39:26 -0700 Subject: [PATCH] Provide instructions for stopping, restarting, removing the nginx container (#1) (cherry picked from commit e9b760157c5c2aad1d3915fb202b64bade0637dc) --- docker-for-mac/index.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/docker-for-mac/index.md b/docker-for-mac/index.md index f1a4330841..341c07bb49 100644 --- a/docker-for-mac/index.md +++ b/docker-for-mac/index.md @@ -126,9 +126,10 @@ Run these commands to test if your versions of `docker`, `docker-compose`, and ` 1. Open a command-line terminal, and run some Docker commands to verify that Docker is working as expected. - 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. + 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. -2. For something more adventurous, start a Dockerized web server. +2. For something more adventurous, start a Dockerized web server. This starts a container that + keeps running in the background until you stop it. ```shell 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 ` >**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. -3. Run `docker ps` while your web server is running to see details on the webserver container. +3. Run `docker ps` to see details on the webserver container and any other running containers. To see + stopped containers as well, use `docker ps -a`. To see only stopped containers, use `docker ps -f "status=exited"`. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 56f433965490 nginx "nginx -g 'daemon off" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 443/tcp webserver +4. To stop a container which runs in the background, use `docker stop ` or `docker stop `, after finding the container using the `docker ps` command. + + ```shell + docker stop 56f433965490 + ``` + +5. To start or restart a container which you have started and stopped before, use the command + `docker start `. + + ```shell + docker start webserver + ``` + +6. To completely remove a stopped container, use the `docker rm ` or + `docker rm ` command. + + ```shell + docker rm webserver + ``` **Want more example applictions?** - For more example walkthroughs that include setting up services and databases in Docker Compose, see [Example Applications](examples.md). ## Preferences