A colleague needs a web server in a Docker container on port 8080, for testing. The busybox image with the httpd server is already on the machine. Docker here is available to root only, so the docker commands go through sudo.
Start the server with the command on the card and look at the list of containers. "Start" prepares the machine.
Start the web server
Start the web server in the web container with the command on the card, then look at the list of containers.
First, predict
What will sudo docker ps show after the server is started?
Now start the exercise, run the command and compare your prediction with the output.
docker run printed a long string, yet docker ps does not list web. Which of these is true?
-
docker psalso ran withsudo, and Docker's containers are shared across the machine: a runningwebwould be listed. -
Docker reports a refusal with a
docker: Error response from daemon: …line. The long string of digits and letters is the ID of the created container. -
Without
--rmDocker does not delete a container: the stoppedwebis still on the machine, andsudo docker ps -ashows it.
The web container was created, but it is not in the list of running ones.