- Containers in OpenStack
- Pradeep Kumar Singh Madhuri Kumari
- 141字
- 2021-07-02 21:17:25
Creating containers
Launching a container is simple, as docker run passes the image name you would like to run and the command to run this within the container. If the image doesn't exist on your local machine, Docker will attempt to fetch it from the public image registry:
$ sudo docker run --name hello_world ubuntu /bin/echo hello world
In the preceding example, the container will start, print hello world, and then stop. Containers are designed to stop once the command executed within them has exited.
As an example, let's run a container using the latest image in Ubuntu. The combination of the -i and -t switches gives you interactive shell access to the container:
$ sudo docker run -it ubuntu root@a5b3bce6ed1b:/# ls bin boot dev etc home lib lib64 media mnt opt proc root
run sbin srv sys tmp usr var