How to create a Data Container for multiple Docker images on Fedora 34

To Create A Data Container for multiple Docker images on Fedora 34

Introduction:

Docker is a group of platforms as service products that enable software to be delivered in containers via OS-level virtualization. BusyBox combines several Unix utilities into a single executable file.

Installation procedure:

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"
HOME_URL="https://fedoraproject.org/"
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: Create a busybox image with a directory named “folder” by using the below command

 [root@linuxhelp ~]# docker create -v /folder --name datacontainer busybox
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
009932687766: Pull complete 
Digest: sha256:afcc7f1ac1b49db317a7196c902e61c6c3c4607d63599ee1a82d702d249a0ccb
Status: Downloaded newer image for busybox:latest
b9e0c1f4bd95ac3a9b7c17d0718e07b0e48d7a26a7f753a1bda1b5645765c9a6

Step 3: Create a file named “test” by using the below command

[root@linuxhelp ~]# touch test

Step 4: Copy the created file to the Container named “datacontainer” by using the below command

[root@linuxhelp ~]# docker cp test datacontainer:/folder

Step 5: List the images by using the below command

 [root@linuxhelp ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
busybox       latest    ec3f0931a6e6   6 days ago     1.24MB
hello-world   latest    feb5d9fea6a5   4 months ago   13.3kB

Step 6: Mount the datacontainer as volume for the Centos images by using the below command

 [root@linuxhelp ~]# docker run --volumes-from datacontainer centos ls /folder
Unable to find image 'centos:latest' locally
latest: Pulling from library/centos
a1d0c7532777: Pull complete 
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
test

Step 7: Mount the datacontainer as volume for the Ubuntu images by using the below command

 [root@linuxhelp ~]# docker run --volumes-from datacontainer ubuntu ls /folder
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
08c01a0ec47e: Pull complete 
Digest: sha256:669e010b58baf5beb2836b253c1fd5768333f0d1dbcb834f7c07a4dc93f474be
Status: Downloaded newer image for ubuntu:latest
Test

With this the process of Creating a Data Container for multiple Docker images on Fedora 34 have been completed.

FAQ
Q
How to Mount the data container as volume for the Container images?
A
Mount the data container as volume for the Container images by "docker run --volumes-from datacontainer "
Q
Is Busy Box a software or Operating System?
A
A software that is located on a higher layer than the operating system and brings together programs in a multi-call executable, offering, through a list of commands, the execution of various tasks.
Q
For what Busy Box is used?
A
Busybox allows programs to perform actions on your phone using Linux (copied from Unix) commands.
Q
What is Busy Box?
A
BusyBox is a software suite that provides several Unix utilities in a single execution.
Q
How to get Bash of the Docker container?
A
To get Bash of the Docker container by using :docker run -it /bin/bash" command