{"id":5566,"date":"2023-09-08T13:42:01","date_gmt":"2023-09-08T11:42:01","guid":{"rendered":"http:\/\/miro.borodziuk.eu\/?p=5566"},"modified":"2024-02-24T18:01:24","modified_gmt":"2024-02-24T17:01:24","slug":"managing-container-images","status":"publish","type":"post","link":"http:\/\/miro.borodziuk.eu\/index.php\/2023\/09\/08\/managing-container-images\/","title":{"rendered":"Managing Container Images"},"content":{"rendered":"<p><!--more--><\/p>\n<p><span style=\"color: #3366ff\">Image Architecture<\/span><\/p>\n<ul>\n<li>A container image basically is a tar file with associated metadata<\/li>\n<li>To build container images in an efficient way, it typically consists of multiple layers<\/li>\n<li>While building an image, a base system image is used<\/li>\n<li>On top of the base system image, the application is installed as an additional layer<\/li>\n<li>Some of the standard images themselves already consist of multiple layers<\/li>\n<li>Using layers ensures that images are built efficiently<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Exploring Image Layers<\/span><\/p>\n<ul>\n<li><code>docker image ls<\/code> shows images stored, including version information using<br \/>\ntags<\/li>\n<li><code>docker image rm<\/code> removes images<\/li>\n<li><code>docker history &lt;imagelD&gt;<\/code> or <code>docker history image:tag<\/code> shows the different layers in the image<\/li>\n<li>Notice that each modification adds an image layer!<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Tagging Images<\/span><\/p>\n<ul>\n<li>Tags allow you to assign names to images, which makes it<br \/>\neasier to manage versions<\/p>\n<ul>\n<li>If no tag is added, &#8220;latest&#8221; is used as the default tag<\/li>\n<\/ul>\n<\/li>\n<li>Manually tag images:<code> docker tag myapache myapache:1.0<\/code>\n<ul>\n<li>Next, using <code>docker image ls | grep myapache<\/code> will show the same image listed twice, as 1.0 and as latest<\/li>\n<\/ul>\n<\/li>\n<li>Tags can also be used to identify the target registry\n<ul>\n<li><code>docker tag myapache localhost:5000\/myapache:1.0<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">[root@controller ~]# docker image ls\r\nREPOSITORY   TAG       IMAGE ID       CREATED       SIZE\r\nubuntu       latest    3db8720ecbf5   9 days ago    77.9MB\r\nmariadb      latest    2f62d6fb2c8b   10 days ago   405MB\r\nbusybox      latest    3f57d9401f8d   5 weeks ago   4.26MB\r\nhttpd        latest    2776f4da9d55   5 weeks ago   167MB\r\n\r\n[root@controller ~]# docker tag mariadb localhost:5000\/mariadb:latest\r\n\r\n[root@controller ~]# docker image ls\r\nREPOSITORY               TAG       IMAGE ID       CREATED       SIZE\r\nubuntu                   latest    3db8720ecbf5   9 days ago    77.9MB\r\nmariadb                  latest    2f62d6fb2c8b   10 days ago   405MB\r\nlocalhost:5000\/mariadb   latest    2f62d6fb2c8b   10 days ago   405MB\r\nbusybox                  latest    3f57d9401f8d   5 weeks ago   4.26MB\r\nhttpd                    latest    2776f4da9d55   5 weeks ago   167MB\r\n[root@controller ~]# docker image --help\r\n\r\nUsage:  docker image COMMAND\r\n\r\nManage images\r\n\r\nCommands:\r\n  build       Build an image from a Dockerfile\r\n  history     Show the history of an image\r\n  import      Import the contents from a tarball to create a filesystem image\r\n  inspect     Display detailed information on one or more images\r\n  load        Load an image from a tar archive or STDIN\r\n  ls          List images\r\n  prune       Remove unused images\r\n  pull        Download an image from a registry\r\n  push        Upload an image to a registry\r\n  rm          Remove one or more images\r\n  save        Save one or more images to a tar archive (streamed to STDOUT by default)\r\n  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE\r\n\r\nRun 'docker image COMMAND --help' for more information on a command.\r\n\r\n[root@controller ~]# docker image history mariadb:latest\r\nIMAGE          CREATED       CREATED BY                                      SIZE      COMMENT\r\n2f62d6fb2c8b   10 days ago   CMD [\"mariadbd\"]                                0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   EXPOSE map[3306\/tcp:{}]                         0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   ENTRYPOINT [\"docker-entrypoint.sh\"]             0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   COPY docker-entrypoint.sh \/usr\/local\/bin\/ # \u2026   26.1kB    buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   COPY healthcheck.sh \/usr\/local\/bin\/healthche\u2026   9.24kB    buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   VOLUME [\/var\/lib\/mysql]                         0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   RUN |3 GPG_KEYS=177F4010FE56CA3336300305F165\u2026   312MB     buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   RUN |3 GPG_KEYS=177F4010FE56CA3336300305F165\u2026   133B      buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   ARG REPOSITORY=http:\/\/archive.mariadb.org\/ma\u2026   0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   ENV MARIADB_VERSION=1:11.2.3+maria~ubu2204      0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   ARG MARIADB_VERSION=1:11.2.3+maria~ubu2204      0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   LABEL org.opencontainers.image.authors=Maria\u2026   0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   ENV LANG=C.UTF-8                                0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   RUN |1 GPG_KEYS=177F4010FE56CA3336300305F165\u2026   0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   RUN |1 GPG_KEYS=177F4010FE56CA3336300305F165\u2026   14.5MB    buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   ARG GPG_KEYS=177F4010FE56CA3336300305F1656F2\u2026   0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   ENV GOSU_VERSION=1.17                           0B        buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   RUN \/bin\/sh -c groupadd -r mysql &amp;&amp; useradd \u2026   329kB     buildkit.dockerfile.v0\r\n&lt;missing&gt;      10 days ago   \/bin\/sh -c #(nop)  CMD [\"\/bin\/bash\"]            0B\r\n&lt;missing&gt;      10 days ago   \/bin\/sh -c #(nop) ADD file:7f9a3c5a4231ed191\u2026   77.9MB\r\n&lt;missing&gt;      10 days ago   \/bin\/sh -c #(nop)  LABEL org.opencontainers.\u2026   0B\r\n&lt;missing&gt;      10 days ago   \/bin\/sh -c #(nop)  LABEL org.opencontainers.\u2026   0B\r\n&lt;missing&gt;      10 days ago   \/bin\/sh -c #(nop)  ARG LAUNCHPAD_BUILD_ARCH     0B\r\n&lt;missing&gt;      10 days ago   \/bin\/sh -c #(nop)  ARG RELEASE                  0B\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Creating Images<\/span><\/p>\n<p>There are two main approaches to creating an image<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>Using a running container: a container is started, and<br \/>\nmodifications are applied to the container. The <code>docker<\/code><br \/>\n<code>commit<\/code> command is used to write modifications<\/li>\n<li>Using a Dockerfile: a Dockerfile contains instructions for<br \/>\nbuilding an image. Each instruction adds a new layer to the<br \/>\nimage, which offers more control over the files that are<br \/>\nadded to an image at a later stage<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Options tor Customizing Images<\/span><\/p>\n<ul>\n<li>Dockerfile, also known as Containerfile, is a very common way to build<br \/>\ncustom images<\/li>\n<li>It uses a descriptive file using a base image in which commands are executed to customize it<\/li>\n<li><code>docker commit<\/code> commits changes that are made in a running container to the container image, after which <code>docker save<\/code> can be used to save it<\/li>\n<li><code>buildah<\/code> can be used to create, modify and manage container images<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">About Terminology<\/span><\/p>\n<ul>\n<li>Dockerfile is the original terminology, which was introduced by Docker<\/li>\n<li>OCI has standardized the name to Containerfile<\/li>\n<li>Dockerfile should be used while working with docker, Containerfile may be used while working with podman<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Understanding the Process<\/span><\/p>\n<ul>\n<li>First, you&#8217;ll create a working directory: each project should have its own<br \/>\nproject directory<\/li>\n<li>Next, you&#8217;ll write the Dockerfile: the Dockerfile contains instructions to build the image<\/li>\n<li>The most important part in the Dockerfile is the default command it will start, which is done by using ENTRYPOINT or CMD<\/li>\n<li>Finally, build the image with<code> docker build<\/code> or <code>podman build<\/code><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">About Terminology<\/span><\/p>\n<ul>\n<li>Dockerfile was introduced by Docker to automate building container<br \/>\nimages<\/li>\n<li>In Red Hat environments, the word Containerfile is preferred<\/li>\n<li>Currently, <code>docker<\/code> only supports Dockerfile and <code>podman<\/code> works with Dockerfile as well as Containerfile<\/li>\n<li>For this reason, in this lesson I&#8217;m using the word Dockerfile<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Writing a Dockerfile<\/span><\/p>\n<ul>\n<li>Each Dockerfile starts with <code>FROM<\/code>, identifying the base image to use\n<ul>\n<li>Next, instructions are executed in that base image<\/li>\n<li>Instructions are executed in the order specified<\/li>\n<\/ul>\n<\/li>\n<li>Each Dockerfile instruction runs in an independent container, using an intermediate image built from a previous command, which means that adding multiple instructions results in multiple layers<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Understanding ENTRYPOINT<\/span><\/p>\n<ul>\n<li><code>ENTRYPOINT<\/code> is the default command to be processed<\/li>\n<li>If not specified, <code>\/bin\/sh -c<\/code> is executed as the default command<\/li>\n<li>Arguments to the <code>ENTRYPOINT<\/code> command may be specified separately<br \/>\nusing <code>CMD<\/code><\/p>\n<ul>\n<li><code>ENTRYPOINT [\"command\"]; ENTRYPOINT [\"\/usr\/sbin\/httpd\"]<\/code><\/li>\n<li><code>CMD [\"arg1\",\"arg2\"]; CMD [\"-D\", \"FOREGROUND\"]<\/code><\/li>\n<\/ul>\n<\/li>\n<li>If the default command is specified using <code>CMD<\/code> instead of <code>ENTRYPOINT<\/code>, the command is executed as an argument to the default entrypoint <code>sh -c<\/code> which can give unexpected results<\/li>\n<li>If the arguments to the command are specified within the <code>ENTRYPOINT<\/code>, then they are not supposed to be overwritten from the command line<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Understanding Formats<\/span><\/p>\n<ul>\n<li>Options like <code>ADD, COPY, ENTRYPOINT, CMD<\/code> are used in shell form<br \/>\nand in exec form<\/li>\n<li>Shell form is a list of items\n<ul>\n<li><code>ADD \/my\/file \/mydir<\/code><\/li>\n<li><code>ENTRYPOINT \/usr\/bin\/nmap -sn 172.17.0.0\/24<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Exec form is a JSON array of items\n<ul>\n<li><code>ADD [\"\/my\/file\", \"\/mydir\"]<\/code><\/li>\n<li><code>ENTRYPOINT [\"\/usr\/bin\/nmap\", \"-sn\", \"172.17.0.0\/24\"]<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Using Exec form is preferred, as shell form wraps command in a<code> \/bin\/sh -c<\/code> shell, which creates a sometimes unnecessary shellprocess<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Avoiding Multi-layer Images<\/span><\/p>\n<ul>\n<li>Each command used in a Dockerfile creates a new layer and this should be<br \/>\navoided<\/li>\n<li>So don&#8217;t run multiple RUN commands, connect them using &amp;&amp;\n<ul>\n<li><code>RUN yum --disablerepo=* --enablerepo=\"myrepo\" &amp;&amp; yum update -y &amp;&amp; yum install nmap<\/code><\/li>\n<li>To maintain readability, write the commands on different lines using &amp;&amp; \\ at the end of each line:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><code>RUN yum --disablerepo=* --enablerepo=\"rhel7-server-rpms\" &amp;&amp; \\\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 yum update -y &amp;&amp; \\<\/code><br \/>\n<code>yum install -y nginx<\/code><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Building Images with Dockerfile<\/span><\/p>\n<ul>\n<li>To build an image with Dockerfile, use<code> docker build \/ podman build<\/code><\/li>\n<li><code>docker build<\/code> takes 2 arguments: <code>-t name[:tag] directory<\/code><\/li>\n<li>If no tag is specified, the image is tagged as latest\n<ul>\n<li><code>docker build -t myimage<\/code> .<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true \">[root@controller ckad]# cd dockerfile\r\n\r\n[root@controller dockerfile]# ls\r\nDockerfile  sander.repo\r\n\r\n[root@controller dockerfile]# cat Dockerfile\r\nFROM centos:7\r\nMAINTAINER Sander &lt;mail@sandervanvugt.nl&gt;\r\n\r\n# Add repo file\r\nADD .\/sander.repo \/etc\/yum.repos.d\/\r\n\r\n# Install cool software\r\nRUN yum --assumeyes update &amp;&amp; \\\r\nyum --assumeyes install bash nmap iproute &amp;&amp; \\\r\nyum clean all\r\n\r\nENTRYPOINT [\"\/usr\/bin\/nmap\"]\r\nCMD [\"-sn\", \"172.17.0.0\/24\"]\r\n\r\n[root@controller dockerfile]# docker build -t nmap .\r\n[+] Building 1.1s (8\/8) FINISHED                                                                                        docker:default\r\n =&gt; [internal] load build definition from Dockerfile                                                                              0.0s\r\n =&gt; =&gt; transferring dockerfile: 326B                                                                                              0.0s\r\n =&gt; [internal] load metadata for docker.io\/library\/centos:7                                                                       1.0s\r\n =&gt; [internal] load .dockerignore                                                                                                 0.0s\r\n =&gt; =&gt; transferring context: 2B                                                                                                   0.0s\r\n =&gt; [internal] load build context                                                                                                 0.0s\r\n =&gt; =&gt; transferring context: 32B                                                                                                  0.0s\r\n =&gt; [1\/3] FROM docker.io\/library\/centos:7@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4                 0.0s\r\n =&gt; CACHED [2\/3] ADD .\/sander.repo \/etc\/yum.repos.d\/                                                                              0.0s\r\n =&gt; CACHED [3\/3] RUN yum --assumeyes update &amp;&amp; yum --assumeyes install bash nmap iproute &amp;&amp; yum clean all                         0.0s\r\n =&gt; exporting to image                                                                                                            0.0s\r\n =&gt; =&gt; exporting layers                                                                                                           0.0s\r\n =&gt; =&gt; writing image sha256:6d3d4ddc5fcc659cb18a3b53f6602ff0630e6a64edba6d040c00a05e1dfbc221                                      0.0s\r\n =&gt; =&gt; naming to docker.io\/library\/nmap                                                                                           0.0s\r\n\r\n[root@controller dockerfile]# docker images\r\nREPOSITORY               TAG       IMAGE ID       CREATED         SIZE\r\nnmap                     latest    6d3d4ddc5fcc   5 minutes ago   387MB\r\nubuntu                   latest    3db8720ecbf5   11 days ago     77.9MB\r\nmariadb                  latest    2f62d6fb2c8b   12 days ago     405MB\r\nlocalhost:5000\/mariadb   latest    2f62d6fb2c8b   12 days ago     405MB\r\nbusybox                  latest    3f57d9401f8d   5 weeks ago     4.26MB\r\nhttpd                    latest    2776f4da9d55   5 weeks ago     167MB\r\n\r\n[root@controller dockerfile]# docker run nmap\r\n\r\nStarting Nmap 6.40 ( http:\/\/nmap.org ) at 2024-02-24 12:00 UTC\r\nNmap scan report for 172.17.0.1\r\nHost is up (0.000097s latency).\r\nMAC Address: 02:42:68:FE:8C:0D (Unknown)\r\nNmap scan report for 172.17.0.2\r\nHost is up (0.000025s latency).\r\nMAC Address: 02:42:AC:11:00:02 (Unknown)\r\nNmap scan report for 172.17.0.3\r\nHost is up (0.000031s latency).\r\nMAC Address: 02:42:AC:11:00:03 (Unknown)\r\nNmap scan report for 172.17.0.4\r\nHost is up (0.000022s latency).\r\nMAC Address: 02:42:AC:11:00:04 (Unknown)\r\nNmap scan report for 172.17.0.5\r\nHost is up (0.000037s latency).\r\nMAC Address: 02:42:AC:11:00:05 (Unknown)\r\nNmap scan report for 28661016aea2 (172.17.0.6)\r\nHost is up.\r\nNmap done: 256 IP addresses (6 hosts up) scanned in 4.50 seconds\r\n\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Using docker commit<\/span><\/p>\n<ul>\n<li>After making changes to a container, you can save it to an image<\/li>\n<li>Use <code>docker commit<\/code> to do so\n<ul>\n<li><code>docker commit -m \"custom web server\" -a \"Miro\" myapache myapache<\/code><\/li>\n<li>Use <code>docker images<\/code> to verify<\/li>\n<\/ul>\n<\/li>\n<li>Next, use <code>docker save -o myapache.tar myapache<\/code> and transport it to anywhere you&#8217;d like<\/li>\n<li>From another system, use <code>docker load -i myapache.tar<\/code> to import it as an image<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">[root@controller ckad]# docker ps\r\nCONTAINER ID   IMAGE           COMMAND                  CREATED      STATUS      PORTS                                   NAMES\r\ncc94dcd26493   ubuntu:latest   \"\/bin\/bash\"              4 days ago   Up 4 days                                           sweet_mclean\r\na229ccfd0f81   mariadb         \"docker-entrypoint.s\u2026\"   4 days ago   Up 4 days   3306\/tcp                                mydb\r\na96d522c5b20   busybox         \"sh\"                     4 days ago   Up 4 days                                           cool_pasteur\r\n132a8601bc20   httpd           \"httpd-foreground\"       4 days ago   Up 4 days   0.0.0.0:8080-&gt;80\/tcp, :::8080-&gt;80\/tcp   myapache\r\n\r\n[root@controller ckad]# docker exec -it myapache.sh\r\n\"docker exec\" requires at least 2 arguments.\r\nSee 'docker exec --help'.\r\n\r\nUsage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]\r\n\r\nExecute a command in a running container\r\n\r\n[root@controller ckad]# docker exec -it myapache sh\r\n\r\n# echo hello &gt; \/tmp\/hellofile\r\n\r\n# ls -l \/tmp\/hellofile\r\n-rw-r--r-- 1 root root 6 Feb 24 13:12 \/tmp\/hellofile\r\n\r\n# exit\r\n\r\n[root@controller ckad]# docker diff myapache\r\nC \/tmp\r\nA \/tmp\/hellofile\r\nC \/var\r\nA \/var\/www\r\nA \/var\/www\/html\r\nC \/usr\r\nC \/usr\/local\r\nC \/usr\/local\/apache2\r\nC \/usr\/local\/apache2\/logs\r\nA \/usr\/local\/apache2\/logs\/httpd.pid\r\n\r\n[root@controller ckad]# docker commit --help | more\r\n\r\nUsage:  docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]\r\n\r\nCreate a new image from a container's changes\r\n\r\nAliases:\r\n  docker container commit, docker commit\r\n\r\nOptions:\r\n  -a, --author string    Author (e.g., \"John Hannibal Smith &lt;hannibal@a-team.com&gt;\")\r\n  -c, --change list      Apply Dockerfile instruction to the created image\r\n  -m, --message string   Commit message\r\n  -p, --pause            Pause container during commit (default true)\r\n[root@controller ckad]# docker commit my\r\nError response from daemon: No such container: my\r\n\r\n[root@controller ckad]# docker commit myapache myapache\r\nsha256:3b7004c30a95887e955966a9898f985e0e1785f183d09745ed83548da5f77f82\r\n\r\n[root@controller ckad]# docker images\r\nREPOSITORY               TAG       IMAGE ID       CREATED             SIZE\r\nmyapache                 latest    3b7004c30a95   8 seconds ago       167MB\r\nnamp                     latest    6d3d4ddc5fcc   About an hour ago   387MB\r\nnmap                     latest    6d3d4ddc5fcc   About an hour ago   387MB\r\nubuntu                   latest    3db8720ecbf5   11 days ago         77.9MB\r\nmariadb                  latest    2f62d6fb2c8b   12 days ago         405MB\r\nlocalhost:5000\/mariadb   latest    2f62d6fb2c8b   12 days ago         405MB\r\nbusybox                  latest    3f57d9401f8d   5 weeks ago         4.26MB\r\nhttpd                    latest    2776f4da9d55   5 weeks ago         167MB\r\n\r\n[root@controller ckad]# docker save -o myapache.tar myapache\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff\">Lab: Creating Custom Container Images<\/span><\/p>\n<ul>\n<li>Create a Dockerfile that creates an image that meets the<br \/>\nfollowing requirements:<\/li>\n<li>Based on fedora<\/li>\n<li>Contains the packages containing the <code>ps<\/code> command as well as network tools<\/li>\n<li>Should run the sshd process<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true \">[root@controller ckad]# mkdir lesson1lab\r\n[root@controller ckad]# cp dockerfile\/* lesson1lab\/\r\n[root@controller lesson1lab]# vi Dockerfile\r\n[root@controller lesson1lab]# vim Dockerfile\r\n[root@controller lesson1lab]# cat Dockerfile\r\nFROM fedora\r\nMAINTAINER Miro &lt;mborodziuk@yahoo.com&gt;\r\n\r\n# Install cool software\r\nRUN     dnf -y update &amp;&amp; \\\r\n        dnf -y install procps-ng iproute openssh-server &amp;&amp; \\\r\n        dnf clean all\r\n\r\nCMD [\"\/usr\/sbin\/sshd\"]\r\n\r\n[root@controller lesson1lab]# docker build -t mysshd\r\nERROR: \"docker buildx build\" requires exactly 1 argument.\r\nSee 'docker buildx build --help'.\r\n\r\nUsage:  docker buildx build [OPTIONS] PATH | URL | -\r\n\r\nStart a build\r\n\r\n[root@controller lesson1lab]# docker build -t mysshd .\r\n[+] Building 119.4s (6\/6) FINISHED                                                                                      docker:default\r\n =&gt; [internal] load build definition from Dockerfile                                                                              0.1s\r\n =&gt; =&gt; transferring dockerfile: 235B                                                                                              0.0s\r\n =&gt; [internal] load metadata for docker.io\/library\/fedora:latest                                                                  2.0s\r\n =&gt; [internal] load .dockerignore                                                                                                 0.0s\r\n =&gt; =&gt; transferring context: 2B                                                                                                   0.0s\r\n =&gt; [1\/2] FROM docker.io\/library\/fedora:latest@sha256:61864fd19bbd64d620f338eb11dae9e8759bf7fa97302ac6c43865c48dccd679            6.2s\r\n =&gt; =&gt; resolve docker.io\/library\/fedora:latest@sha256:61864fd19bbd64d620f338eb11dae9e8759bf7fa97302ac6c43865c48dccd679            0.0s\r\n =&gt; =&gt; sha256:5f878605acd6f24f3f11e4085544caf61b046378b31d6b3aa0677a7a3dbe0a17 2.00kB \/ 2.00kB                                    0.0s\r\n =&gt; =&gt; sha256:353b74d8db1cf655e87c780b9ac49f52ed72dfaa3ecc4bb0e9245e72c98a45b5 64.61MB \/ 64.61MB                                  0.9s\r\n =&gt; =&gt; sha256:61864fd19bbd64d620f338eb11dae9e8759bf7fa97302ac6c43865c48dccd679 975B \/ 975B                                        0.0s\r\n =&gt; =&gt; sha256:830a6bcb5c9b30bfa77479b747a904bed02151e9de7ceeb8a1d117b574571fa4 529B \/ 529B                                        0.0s\r\n =&gt; =&gt; extracting sha256:353b74d8db1cf655e87c780b9ac49f52ed72dfaa3ecc4bb0e9245e72c98a45b5                                         4.7s\r\n =&gt; [2\/2] RUN  dnf -y update &amp;&amp;  dnf -y install procps-ng iproute openssh-server &amp;&amp;  dnf clean all                              109.3s\r\n =&gt; exporting to image                                                                                                            1.2s\r\n =&gt; =&gt; exporting layers                                                                                                           1.2s\r\n =&gt; =&gt; writing image sha256:88ace079c8650240999a2d9169cc4600d6c25a84ef3dd817e6255095dbfd7bc9                                      0.0s\r\n =&gt; =&gt; naming to docker.io\/library\/mysshd                                                                                         0.0s\r\n\r\n[root@controller lesson1lab]# docker images\r\nREPOSITORY               TAG       IMAGE ID       CREATED              SIZE\r\nmysshd                   latest    88ace079c865   About a minute ago   231MB\r\nmyapache                 latest    3b7004c30a95   37 minutes ago       167MB\r\nnamp                     latest    6d3d4ddc5fcc   2 hours ago          387MB\r\nnmap                     latest    6d3d4ddc5fcc   2 hours ago          387MB\r\nubuntu                   latest    3db8720ecbf5   11 days ago          77.9MB\r\nmariadb                  latest    2f62d6fb2c8b   12 days ago          405MB\r\nlocalhost:5000\/mariadb   latest    2f62d6fb2c8b   12 days ago          405MB\r\nbusybox                  latest    3f57d9401f8d   5 weeks ago          4.26MB\r\nhttpd                    latest    2776f4da9d55   5 weeks ago          167MB\r\n\r\n[root@controller lesson1lab]# docker run mysshd\r\nsshd: no hostkeys available -- exiting.\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,92],"tags":[],"_links":{"self":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/5566"}],"collection":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/comments?post=5566"}],"version-history":[{"count":18,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/5566\/revisions"}],"predecessor-version":[{"id":5584,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/5566\/revisions\/5584"}],"wp:attachment":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/media?parent=5566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/categories?post=5566"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/tags?post=5566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}