Docker Image: Ubuntu
-
Get the Ubuntu Docker image
docker pull ubuntu Using default tag: latest latest: Pulling from library/ubuntu a70d879fa598: Pull complete 10e6159c56c0: Pull complete Digest: sha256:3c9c713e0979e9bd6061ed52ac1e9e1f246c9495aa063619d9d695fb8039aa1f Status: Downloaded newer image for ubuntu:latest docker.io/library/ubuntu:latest -
Show a list of previously downloaded docker images
docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker101tutorial latest ac415588360d 4 days ago 28MB camunda/camunda-bpm-platform run-latest c1b49a5b4227 10 days ago 243MB stonebranch/universal-agent latest eca81e31c6a3 11 days ago 1.53GB busybox latest 388056c9a683 11 days ago 1.23MB ubuntu latest 26b77e58432b 2 weeks ago 72.9MB -
Start a detached container based on the ubuntu image with a friendly name of MyUbuntuContainer
docker run -t -d --name MyUbuntuContainer ubuntu 2a20d14e8c8a6d47ff99df07212759b48e93451c74ec81e0b0d0769d9808b56e -
Show list of all docker containers
docker ps --all CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2a20d14e8c8a ubuntu "/bin/bash" 26 seconds ago Up 26 seconds MyUbuntuContainer b57fbf4820d7 stonebranch/universal-agent:latest "./ua_entrypoint" About an hour ago Up About an hour 7878/tcp, 7887/tcp My-UAG1 647c71dd239e camunda/camunda-bpm-platform:run-latest "/sbin/tini -- ./cam…" 4 days ago Up 7 hours 8000/tcp, 9404/tcp, 0.0.0.0:8080->8080/tcp MyCamunda -
Start an interactive
bashshell within the container.docker exec -it MyUbuntuContainer bash root@2a20d14e8c8a:/# -
Now run some commands within the interactive shell e.g.,
hostname,id,ls -l:root@2a20d14e8c8a:/# hostname (1) 2a20d14e8c8a root@2a20d14e8c8a:/# root@2a20d14e8c8a:/# id (2) uid=0(root) gid=0(root) groups=0(root) root@2a20d14e8c8a:/# root@2a20d14e8c8a:/# ls -l (3) total 48 lrwxrwxrwx 1 root root 7 Apr 1 01:23 bin -> usr/bin drwxr-xr-x 2 root root 4096 Apr 15 2020 boot drwxr-xr-x 5 root root 360 Apr 19 23:33 dev drwxr-xr-x 1 root root 4096 Apr 19 23:33 etc drwxr-xr-x 2 root root 4096 Apr 15 2020 home lrwxrwxrwx 1 root root 7 Apr 1 01:23 lib -> usr/lib lrwxrwxrwx 1 root root 9 Apr 1 01:23 lib32 -> usr/lib32 lrwxrwxrwx 1 root root 9 Apr 1 01:23 lib64 -> usr/lib64 lrwxrwxrwx 1 root root 10 Apr 1 01:23 libx32 -> usr/libx32 drwxr-xr-x 2 root root 4096 Apr 1 01:23 media drwxr-xr-x 2 root root 4096 Apr 1 01:23 mnt drwxr-xr-x 2 root root 4096 Apr 1 01:23 opt dr-xr-xr-x 192 root root 0 Apr 19 23:33 proc drwx------ 2 root root 4096 Apr 1 01:26 root drwxr-xr-x 1 root root 4096 Apr 3 00:53 run lrwxrwxrwx 1 root root 8 Apr 1 01:23 sbin -> usr/sbin drwxr-xr-x 2 root root 4096 Apr 1 01:23 srv dr-xr-xr-x 11 root root 0 Apr 19 23:33 sys drwxrwxrwt 2 root root 4096 Apr 1 01:26 tmp drwxr-xr-x 1 root root 4096 Apr 1 01:23 usr drwxr-xr-x 1 root root 4096 Apr 1 01:26 var1 Execute the hostnamecommand.2 Execute the idcommand.3 Execute the ls -lcommand.