How to Build Docker image using Docker files on Fedora 34
To Build Docker image using Docker files on Fedora 34
Introduction:
Docker images are unchangeable files that contain source code, libraries, dependencies, tools, and other files that are needed to run an application.
Step 1: Check the OS version by using the below command
[root@linuxhelp ~]# cat /etc/os-release
NAME=Fedora
VERSION="34 (Workstation Edition)"
ID=fedora
VERSION_ID=34
VERSION_CODENAME=""
PLATFORM_ID="platform:f34"
PRETTY_NAME="Fedora 34 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:34"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=34
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=34
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation
Step 2: To check the docker installed status by using the below command
[root@linuxhelp ~]# dnf list --installed | grep docker
containerd.io.x86_64 1.4.12-3.1.fc34 @docker-ce-stable
docker-ce.x86_64 3:20.10.12-3.fc34 @docker-ce-stable
docker-ce-cli.x86_64 1:20.10.12-3.fc34 @docker-ce-stable
docker-ce-rootless-extras.x86_64 20.10.12-3.fc34 @docker-ce-stable
docker-scan-plugin.x86_64 0.12.0-3.fc34 @docker-ce-stable
Step 3: To create directory for the docker file by using the below command
[root@linuxhelp ~]# mkdir dockerfiles
Step 4: To open the configuration file by using the below command
[root@linuxhelp ~]# vim dockerfiles/dockerfile
# Getting image from docker hub
FROM httpd
RUN apt-get update
CMD ["echo","Apache web server image"]
Step 5: To run the docker build using the below command
[root@linuxhelp ~]# docker build dockerfiles/
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM httpd
latest: Pulling from library/httpd
5eb5b503b376: Pull complete
a43a76ccc967: Pull complete
942bd346e7f7: Pull complete
cdb155854ae6: Pull complete
10c4d45228bf: Pull complete
Digest: sha256:5cc947a200524a822883dc6ce6456d852d7c5629ab177dfbf7e38c1b4a647705
Status: Downloaded newer image for httpd:latest
---> a8ea074f4566
Step 2/3 : RUN apt-get update
---> Running in c1de879c6538
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
Get:5 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [116 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2596 B]
Fetched 8501 kB in 3s (2969 kB/s)
Reading package lists...
Removing intermediate container c1de879c6538
---> 5ef582a7ea23
Step 3/3 : CMD ["echo","Apache web server image"]
---> Running in 99ffe51c129a
Removing intermediate container 99ffe51c129a
---> 4c078ce14461
Successfully built 4c078ce14461
Step 6: To run the docker image command by using the below command
[root@linuxhelp ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 4c078ce14461 18 seconds ago 161MB
httpd latest a8ea074f4566 2 weeks ago 144MB
hello-world latest feb5d9fea6a5 4 months ago 13.3kB
Step 7: To check the docker image running status by using the below command
[root@linuxhelp ~]# docker run 4c078ce14461
Apache web server image
By this to build Docker images using Docker file on Fedora 34 have been completed
Q
Does Docker have OS images?
A
Yes, its have OS images.
Q
Which command is used to create a Docker image from a Dockerfile?
A
To create a Docker image from a Dockerfile use the command "docker build".
Q
Is it possible to create Docker image?
A
Yes, This script is called a Dockerfile.
Q
What is a Docker Container?
A
A Docker container is a virtualized run-time environment where users can isolate applications from the underlying system.
These containers are compact, portable units in which you can start up an application quickly and easily.
These containers are compact, portable units in which you can start up an application quickly and easily.
Q
What is a Docker Image?
A
A Docker image is an unchangeable file that contains the source code, libraries, dependencies, tools, and other files needed for an application to run.