Question : The Nautilus DevOps team is testing applications containerization, which issupposed to be migrated on docker container-based environments soon. In today's stand-up meeting one of the team members has been assigned a task to create and test a docker container with certain requirements. Below are more details:
a. On App Server 3 in Stratos DC pull ubuntu image (preferably latest tag but others should work too).
b. Create a new container with name media from the image you just pulled.
c. Map the host volume /opt/dba with container volume /var. There is an sample.txt file present on same server under /tmp; copy that file to /opt/dba. Also please keep the container in running state.
Please Note:- Perform the below commands based on your question server, user name & other details that might differ. So please read the task carefully before executing it. All the Best 👍
Solution:
1. At first login on app server & Switch to the root user
thor@jump_host
/$ ssh banner@stapp03 The authenticity
of host 'stapp03 (172.16.238.12)' can't be established. ECDSA key
fingerprint is SHA256:pAuLYTaL+DJ9PZla//bv+6GOgrYcoDe6al9KUjcymmA. ECDSA key
fingerprint is MD5:18:ff:40:6f:6b:5b:95:cb:67:18:7a:a9:57:f6:53:92. Are you sure you
want to continue connecting (yes/no)? yes Warning:
Permanently added 'stapp03,172.16.238.12' (ECDSA) to the list of known hosts. banner@stapp03's
password: [banner@stapp03
~]$ [banner@stapp03
~]$ sudo su - We trust you
have received the usual lecture from the local System Administrator.
It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great
responsibility. [sudo] password
for banner: [root@stapp03
~]# |
2. Run the Below command to check existing docker images
[root@stapp03
~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE [root@stapp03
~]# |
[root@stapp03
~]# docker pull ubuntu:latest latest: Pulling
from library/ubuntu a31c7b29f4ad:
Pull complete Digest: sha256:b3e2e47d016c08b3396b5ebe06ab0b711c34e7f37b98c9d37abe794b71cea0a2 Status:
Downloaded newer image for ubuntu:latest docker.io/library/ubuntu:latest [root@stapp03
~]# |
[root@stapp03
~]# cp /tmp/sample.txt /opt/dba [root@stapp03
~]# |
5. Run docker container from the image with given name and path
[root@stapp03
~]# docker run --name media -v
/opt/dba:/var -d -it ubuntu:latest 00aebc3928e31e8a21f20c599539b23504b5c02ed3ecc92b7f3bc68028012fbb [root@stapp03
~]# |
6. Validate the task by login on docker container and list /var
[root@stapp03
~]# docker ps CONTAINER
ID IMAGE COMMAND CREATED STATUS PORTS NAMES 00aebc3928e3 ubuntu:latest "bash" About a minute ago Up About a minute media [root@stapp03
~]# [root@stapp03
~]# docker exec -it 00aebc3928e3
/bin/bash root@00aebc3928e3:/#
ll /var total 12 drwxr-xr-x 2 root root 4096 Jul 16 14:37 ./ drwxr-xr-x 17
root root 4096 Jul 16 14:39 ../ -rw-r--r-- 1 root root 23 Jul 16 14:37 sample.txt root@00aebc3928e3:/#
root@00aebc3928e3:/# |
Happy Learning!!!!
0 Comments