Docker series: 2. Create your first container.
Published in
2 min readOct 5, 2019
Below are the commands which can be used to run the container,
Use docker run to create your first container.
[root@machine1 ~]# docker run -i -t --name "mycontainer" centos:latest /bin/bash
Unable to find image 'centos:latest' locally
latest: Pulling from library/centos
8ba884070f61: Pull complete
Digest: sha256:a799dd8a2ded4a83484bbae769d97655392b3f86533ceb7dd96bbac929809f3c
Status: Downloaded newer image for centos:latest
[root@f6738e50ac22 /]# hostname -f
f6738e50ac22
[root@f6738e50ac22 /]# uname -r
3.10.0-957.1.3.el7.x86_64
[root@f6738e50ac22 /]# uname -a
Linux f6738e50ac22 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@f6738e50ac22 /]# ps -elf
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 1 0 0 80 0 - 2955 do_wai 22:20 pts/0 00:00:00 /bin/bash
4 R root 17 1 0 80 0 - 12935 - 22:21 pts/0 00:00:00 ps -elf
As you can see you have launched the container with command /bin/bash.
If you login to another container, you would see the container which is running,
[root@machine1 ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6738e50ac22 centos:latest “/bin/bash” 2 minutes ago Up 2 minutes mycontainer
[root@machine1 ~]#
You can also see all docker images which are pulled as,
[root@machine1 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 4c108a37151f 4 weeks ago 64.2MB
centos latest 9f38484d220f 4 months ago 202MB
hello-world latest fce289e99eb9 6 months ago 1.84kB
Series next read:
https://medium.com/cloudscoop/cloudscoop-docker-series-create-docker-hub-account-88c2c3638400