71.0k views
4 votes
How do you instantiate a container called 'myweb', running non-interactively, from an image called 'httpd:latest'?

A) docker create --name myweb httpd:latest
B) docker run -d --name myweb httpd:latest
C) docker start -d --name myweb httpd:latest
D) docker launch --name myweb httpd:latest

User Bomaz
by
7.6k points

1 Answer

2 votes

Final answer:

To run a container called 'myweb' from the image 'httpd:latest' in detached mode, the correct Docker command is 'docker run -d --name myweb httpd:latest'. This creates and starts the container in the background.

Step-by-step explanation:

To instantiate (create and run) a container called 'myweb' from an image called 'httpd:latest' and have it run non-interactively in the background, you would use the Docker command with the run option combined with the -d flag for detached mode, and --name to specify the name of the container. The correct command is:

B) docker run -d --name myweb httpd:latest

This command pulls the 'httpd:latest' image if it's not available locally, creates a container with the name 'myweb', and starts it in detached mode, meaning the container runs in the background. It's important not to confuse this with the docker create command, which creates a container but does not start it, or the docker start command, which is used to start an existing stopped container.

User Simon Kagwi
by
8.2k points