User Tools

Site Tools


docker:launch_a_docker_container

This is an old revision of the document!


Docker - Launch a Docker Container

Launching a container is simple as docker run + the image name you would like to run + the command to run within the container. If the image doesn't exist on your local machine, Docker will attempt to fetch it from the public image registry. It’s important to note that containers are designed to stop once the command executed within them has exited. For example, if you ran /bin/echo hello world as your command, the container will start, print hello world and then stop:

docker run ubuntu /bin/echo hello world

Let’s launch an Ubuntu container and install Apache inside of it using the bash prompt:

docker run -t -i ubuntu /bin/bash

The -t and -i flags allocate a pseudo-tty and keep stdin open even if not attached. This will allow you to use the container like a traditional VM as long as the bash prompt is running. Install Apache with apt-get update && apt-get install apache2. You’re probably wondering what address you can connect to in order to test that Apache was correctly installed…we’ll get to that after we commit the container.

docker/launch_a_docker_container.1476693342.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki