docker:create_a_container
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
docker:create_a_container [2020/04/15 18:52] – created peter | docker:create_a_container [2020/05/13 08:37] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Docker - Create a container ====== | ||
- | |||
- | Create a contain simply run using **docker run** + the image name you would like to run + the command to run within the container. | ||
- | |||
- | If the image doesn' | ||
- | |||
- | 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: | ||
- | |||
- | <code bash> | ||
- | docker run ubuntu /bin/echo hello world | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE**: | ||
- | </ | ||
- | |||
- | |||
- | ---- | ||
- | |||
- | An alternative method is: | ||
- | |||
- | <code bash> | ||
- | docker run -ti ubuntu | ||
- | </ | ||
- | |||
- | * **-t**: | ||
- | * **-i**: | ||
- | |||
- | This allows continuous use of the container until the terminal is exited by running the " | ||
- | |||
- | |||
- | When the container is created, it is given its container ID and a randomly-generated name. The command-line prompt will changes to indicate we're inside the container as the root user, followed by the 12 character container ID. | ||
- | |||
- | For example: | ||
- | |||
- | <code bash> | ||
- | root@11cc47339ee1:/# | ||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
docker/create_a_container.1586976730.txt.gz · Last modified: 2020/07/15 09:30 (external edit)