docker operation and maintenance questions of cloud computing technology and application competition question bank

Posted by cretaceous on Thu, 17 Feb 2022 14:20:35 +0100

In the process of writing, small mistakes are welcome to correct

The following IP details are used:
Server: 192.168.182.50
Client: 192.168.182.60

According to the software package provided, build the rancher platform. Query the home page of rancher management platform through curl command, and input the above query command and results into the answer box.

curl http://192.168.182.50:8080/env/la5/apps/stacks

According to the software package provided, deploy Gogs through the "app store", modify the web page access port to 9093, access the user list through curl command, and submit the execution result text to the answer box.

curl http://192.168.182.60:9093/explore/users

Deploy elasticsearch 2 through the "app store" according to the software package provided x. Modify the web page access port to 9094, access the home page through curl command, and submit the execution result text to the answer box.

https://start.firefoxchina.cn curl http://192.168.182.60:9094/

According to the software package provided, deploy Grafana through the "app store", modify the web page access port to 9090, access the home page through curl command, and submit the execution result text to the answer box.

curl http:192.168.182.60:9090/graph

According to the software package provided, deploy Grafana through the "app store", access port 3000, use curl command to access port 3000 of Grafana service, and submit the execution result text to the answer box.

curl http://192.168.182.60:3000

On the server node, modify the configuration file to make the warehouse point to the registry node created by ourselves. Use the docker info command to view the warehouse point of the modified docker. The parameters of the configuration file and the method of executing the docker info command will be added

#vi  /etc/sysconfig/docker

ADD_REGISTRY='add-registry 192.168.182.50:5000'
INSECURE_REGISTRY='insecure-registry 192.168.182.50:5000'

#docker info 

When building the rancher platform, you need to turn on the kernel forwarding function of the system. Please submit the parameters of turning on the kernel forwarding function to the answer box in text form.

#sysctl -p 

net.ipv4.ip_forward=1
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0

When using the docker api to query information, we need to modify the docker configuration file and add an OPTIONS to make the api function available. Please submit the added OPTIONS parameter to the answer box in the form of text.

#vi /usr/lib/systemd/system/docker.service

\ -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

Configure the docker container to realize the load balancing of nginx. If you need to modify the configuration file of nginx, please submit the parameters defining tomcat load balancing to the answer box in text form

upstream wei {

    server 10.0.6.126:32768;

    server 10.0.6.126:32769;

On the server node, use the netstat command to query the warehouse listening port number. After the query, use the lsof command (if the command does not exist, install it manually) to query the processes using this port number. Submit all the above operation commands and output results to the answer box in text form.

#yum install net-tools 
#netstart -ntpl
#lsof -i:5000

On the server node, query the docker image warehouse PID through the netstat command (if the command does not exist, install it manually), and use the top command to query the resource usage of the PID queried in the previous step. Submit all the above operation commands and output results to the answer box in text form.

#netstat -ntpl
#top -p 1184

At the server node, query the last five logs of the docker registry container through the docker command, and submit all the above operation commands and output results to the answer box in text form.

#docker ps | grep registry
#docker logs --tail=5 ID

At the server node, query the process number of the rancher/server container, establish the namespace / var/run/netns and connect with the rancher/server container. Query the ip of the container through the relevant commands of ip netns, and fill the above operation commands and inspection results into the answer box.

#docker inspect -f {{.State.Pid}} ID
#mkdir /var/run/netns
#ln -s /proc/1377/ns/net  /var/run/netns/rancher-server
#ip netns list / / displays all named network namespace s
 (It's actually showing /var/run/netns All in the directory network namespace Object:)
#ip netns exec rancher-server ip a

Query the mounting status of the current cgroup in the server node, and fill the above operation commands and inspection results into the answer box.

mount -t cgroup  //-t vfstype specifies the type of file system

Create a cgroup controlled by memory in the server node, named xiandian. After creation, move the current process to this cgroup, query the process ID in the cgroup through cat related commands, and fill the above operation commands and inspection results into the answer box.

mkdri /sys/fs/cgroup/memory/xiandian
echo $$  //Returns the PID of the login shell
sudo sh -c "echo $$>> /sys/fs/cgroup/memory/xiandian/tasks"
cat /proc/956/cgroup

On the server node, create a CPU controlled cgroup named xiandian. Assuming that the process number is 8888, it always occupies the CPU utilization rate and reaches 100%, which seriously affects the normal operation of the system. Adjust the CPU related knowledge quota of cgroup to 30% in this operation. Fill the above operation commands and inspection results into the answer box.

mkdir /sys/fs/cgroup/cpu/xiandian
echo 30000 > /sys/fs/cgroup/cpu/xiandian/cpu.cfs_quota_us
echo 8888 > /sys/fs/cgroup/cpu/xiandian/tasks

On the server node, use nginx image to create a container named 1daoyun. Only 0 kernel can be used. Nginx: latest is used for the image. Check the kernel usage by viewing the Cgroup related files. Fill the above operation commands and inspection results into the answer box (prompt, first modify the parameters of cpuset.cpus).

docker run -itd --name 1daoyun --cpuset-cpus=0 nginx:latest /bin/bash
cat /sys/fs/cgroup/cpuset/system.slice/docker-ID.scope/cpuset.cpus

Create the / opt/xiandian directory on the server node. After creation, start the container named Xiandian dir and mirrored as nginx:latest, and specify this directory as the data volume started by the container. After creation, specify to view the data volume through the inspect command. Fill the above operation commands and inspection results into the answer box

#mkdri /opt/xiandian
#dcoekr run -itd -P --name xiandian-dir -v /opt/xiandian nginx:latest /bin/bash
#docker inspect -f {{.Config.Volumes}} xiandian-dir

Create the / opt / xiandian ro directory on the server node. After creation, start the container named xiandian and mirrored as nginx:latest, and specify this directory as the data volume started by the container. The mount directory is / opt. Set the data volume to read-only mode. After creation, specify to view the Binds in HostConfig through the inspect command. Fill the above operation commands and inspection results into the answer box.

#mkdir /opt/xiandian-ro
#docker run -itd -P --name xianidan -v /opt/xianida-ro:/opt:ro nginx:latest /bin/bash
#docker inspect -f {{.HostConfig.Binds}} xiandian

On the server node, use the relevant command of docker, use mysql:8.0 image to create a container named mysqldb, and use nginx:latest image to create a web container named nginx. The container is connected to the database in the mysqldb container. After the operation is completed, use inspect to view the fields related to the link content, and fill the above operation commands and inspection results into the answer box.

#docker run -itd -P --name mysqldb mysql:8.0 /bin/bash
#docker run -itd -P --name nginxweb --link mysqldb:db nginx:latest /bin/bash
#docker inspect -f {{.HostConfig.Link}} nginxweb

On the server node, view the bridge list through the bridge command (if it does not exist, install the command bridge utils), and fill the above operation commands and inspection results into the answer box.

yun install -y bridge-utils
brctl show

Create XD in the server node_ Br bridge: set the network address and mask of the network to 192.168.2.1/24. After creation, start the bridge and view xd_br for details of network card and bridge, fill the above operation commands and inspection results into the answer box.

brctl addbr xd_br
ip addr add ip/24 dev xd_br
ip link set ip up  //Start Bridge
brctl show
ifconfig xd_br

On the server node, run a container without network environment by using nginx:latest image, use the inspect command to only view the network information of the container, and fill the above operation commands and return results into the answer box in text form.

docker run -itd --net=none nginx:latest /bin/bash
docker inspect -f {{.NetworkSettings.Networks}} nginx:latest

Pull the mysql:8.0 image from the client node, query the docker image list directory after pulling, and fill the above operation commands and inspection results into the answer box.

docker pull mysql:8.0
docker images

Run the mysql:8.0 image on the server node and set the database password to xd_root, map the 13306 port of the host as the 3306 port of the container, and create the database XD after entering the container_ DB, create the user xiandian with the password xd_pass to assign this user to xd_db has all permissions and allows this user to access remotely. After that, use xiandian user to log in to the database remotely, query the database list in the database, and fill the above operation commands and inspection results into the answer box.

#docker run -itd -p 13306:3306 -e MYSQL_ROOT_PASSWORD=xd_root mysql:8.0 
#mysql -uroot -pxd_root
#creat database xd_db
#grant all privileges on xd_db. * to 'xianidan'@'%' identified by 'xd_pass';
#exit
#ip a
#mysql -uxianidan -pxd_pass -hIP "show database;"
[root@server images]# docker run -itdP -e MYSQL_ROOT_PASSWORD=xd_root -p 13306:3306 mysql:8.0
263509211cb33853360407fc76c422236e43506738a70b3c1a4d25b6bfd4c93c
[root@server images]# docker exec -it 26350921 /bin/bash
root@263509211cb3:/# mysql -uroot -pxd_root
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.3-rc-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database xd_db;
Query OK, 1 row affected (0.03 sec)

mysql>  grant all privileges on xd_db.* to 'xiandian'@'%'  identified by 'xd_pass';
Query OK, 0 rows affected, 1 warning (0.03 sec)

mysql> exit
Bye
root@263509211cb3:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
21: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:04 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.4/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:4/64 scope link 
       valid_lft forever preferred_lft forever
root@263509211cb3:/# mysql -uxiandian -pxd_pass -h172.17.0.4 -e "show databases;"
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------------+
| Database           |
+--------------------+
| information_schema |
| xd_db              |
+--------------------+

Export the MySQL image on the server node. The export name is mysql_images.tar, put it in the / media directory, after exporting, check the directory, and fill the above operation commands and inspection results into the answer box.

#docker save mysql :8.0 > /media/mysql_images.tar
#ll /media

On the server node, run the database container, set the database password to 000000, and use the image to mysql:8.0. After running, use the command to export the container with the export name of mysql_container.tar, put it in the / media directory, after exporting, check the directory, and fill the above operation commands and inspection results into the answer box.

#docker run -itd -P -e MYSQL_ROOT_PASSWORD=000000 mysql:8.0 
#docker export container ID > / media / MySQL_ container. tar
#ll /media

Set Tomcat on the server node_ latest. Tar image is imported, labeled as tomcat:latest, uploaded to the warehouse, and the above operation commands and inspection results are filled in the answer box.

[root@server images]# docker load -i tomcat_latest.tar
e27a10675c56: Loading layer [==================================================>]   105 MB/105 MB
851f3e348c69: Loading layer [==================================================>] 24.72 MB/24.72 MB
06f4de5fefea: Loading layer [==================================================>] 7.995 MB/7.995 MB
a4d7b0ac0438: Loading layer [==================================================>] 2.172 MB/2.172 MB
6ef532e39c1e: Loading layer [==================================================>] 3.584 kB/3.584 kB
7ffe9646653b: Loading layer [==================================================>] 1.536 kB/1.536 kB
93742a1ae069: Loading layer [==================================================>] 415.8 MB/415.8 MB
c571db474d75: Loading layer [==================================================>] 400.9 kB/400.9 kB
04178c827c65: Loading layer [==================================================>]  2.56 kB/2.56 kB
c4d99fd86e94: Loading layer [==================================================>] 1.966 MB/1.966 MB
a8e949e6c4fd: Loading layer [==================================================>] 18.87 MB/18.87 MB
f17807115ffa: Loading layer [==================================================>] 2.048 kB/2.048 kB
Loaded image ID: sha256:a92c139758db4c89d0cdeaa641566d0cb3305f9f6d2dbd2ca50dd361c02328da B/2.048 kB
[root@server images]# docker images
<none>                                                      <none>              a92c139758db        5 weeks ago         557.4 MB
[root@server images]# docker tag a92c139758db 10.0.6.126:5000/tomcat:latest
[root@server images]# docker push 10.0.6.126:5000/tomcat:latest
The push refers to a repository [10.0.6.126:5000/tomcat]
f17807115ffa: Pushed 
a8e949e6c4fd: Pushed 
c4d99fd86e94: Pushed 
04178c827c65: Pushed 
c571db474d75: Pushed 
93742a1ae069: Pushed 
7ffe9646653b: Pushed 
6ef532e39c1e: Pushed 
a4d7b0ac0438: Pushed 
06f4de5fefea: Pushed 
851f3e348c69: Pushed 
e27a10675c56: Pushed 
latest: digest: sha256:90b2bee496f433123469c91586b19b6e4b1b0c417356ba0240bdcbea1b474a46 size: 2836
[root@server images]# docker images
10.0.6.126:5000/tomcat                                      latest              a92c139758db        5 weeks ago         557.4 MB

Run the mysql container on the server node, use the image as mysql:8.0, specify the mysql password as 000000, the container runs in the background, use the random mapping port, query the container list after the container runs, and fill the above operation commands and inspection results into the answer box.

#docker run -d -P -e MYSQL_ROOT_PASSWORD=000000 mysql:8.0
#docker ps

Run the mysql container on the server node, use the image as mysql:8.0, specify the mysql password as 000000, the container runs in the background, use the random mapping port, query the container list after the container runs, then stop the running mysql container, query the container status after completion, and fill the above operation commands and inspection results into the answer box.

#docker run -d -e MYSQL_ROOT_PASSWORD=000000 -P mysql:8.0 
#docker ps -a
#Docker stop ID
#docker ps -a

At the server node, start the container stopped in the previous question, query the container status after completion, and fill the above operation commands and inspection results into the answer box

docker start ID
docker ps -a

On the server node, restart the running mysql container and fill the above operation commands and inspection results into the answer box.

docker restart ID

At the server node, execute a command, use exec to obtain the running network socket connection of the Ranger / server container, and fill the above operation command and inspection results into the answer box.

docker exec ID netstat

At the server node, use inspect to only query the network bridge information in the NetworkSettings of the Ranger / server container, and fill the above operation commands and inspection results into the answer box.

docker inspect -f {{.NetworkSettings.Networks.bridge}} ID

At the server node, use inspect to only query the PortBindings information of the Ranger / server container, and fill the above operation commands and inspection results into the answer box.

docker inspect -f {{.HostConfig.PortBindings}} ID

On the server node, use inspect to only query the Ports information in the NetworkSettings of the Ranger / server container, and fill the above operation commands and inspection results into the answer box.

docker inspect -f {{.NetworkSettings.Ports}} ID

At the server node, use inspect to query only the Volumes volume group information of the Ranger / server image, and fill the above operation commands and inspection results into the answer box.

docker inspect -f {{.ContainerConfig.Volumes}} ID

Server node, use inspect to only query the Entrypoint information of the Ranger / server image, and fill the above operation commands and inspection results into the answer box.

docker inspect -f {{.Config.Entrypoint}} ID

At the server node, use the docker command to query the process of the Ranger / server container, and fill the above operation commands and inspection results into the answer box.

docker top ID

At the server node, use the docker command to view the ID of the last container to exit, and fill the above operation commands and inspection results into the answer box.

docker ps -l 

On the server node, create the running MySQL container as an image named mysql_new:latest, query the image after completion, and fill the above operation commands and inspection results into the answer box.

docker commit container ID mysql_new:latest
docker images mysql_new:latest

Query the CPU, memory and other statistical information of the registry container in the server node, and fill the above operation commands and inspection results into the answer box.

[root@server images]# docker stats 6a5d3352e67e

CONTAINER           CPU %               MEM USAGE / LIMIT      MEM %               NET I/O               BLOCK I/O           PIDS
6a5d3352e67e        0.00%               5.52 MiB / 1.954 GiB   0.28%               1.179 GB / 815.4 MB   577.2 MB / 837 MB   0

CONTAINER           CPU %               MEM USAGE / LIMIT      MEM %               NET I/O               BLOCK I/O           PIDS
6a5d3352e67e        0.00%               5.52 MiB / 1.954 GiB   0.28%               1.179 GB / 815.4 MB   577.2 MB / 837 MB   0

CONTAINER           CPU %               MEM USAGE / LIMIT      MEM %               NET I/O               BLOCK I/O           PIDS
6a5d3352e67e        0.00%               5.52 MiB / 1.954 GiB   0.28%               1.179 GB / 815.4 MB   577.2 MB / 837 MB   0

CONTAINER           CPU %               MEM USAGE / LIMIT      MEM %               NET I/O               BLOCK I/O           PIDS
6a5d3352e67e        0.00%               5.52 MiB / 1.954 GiB   0.28%               1.179 GB / 815.4 MB   577.2 MB / 837 MB   0

CONTAINER           CPU %               MEM USAGE / LIMIT      MEM %               NET I/O               BLOCK I/O           PIDS
6a5d3352e67e        0.00%               5.52 MiB / 1.954 GiB   0.28%               1.179 GB / 815.4 MB   577.2 MB / 837 MB   0

CONTAINER           CPU %               MEM USAGE / LIMIT      MEM %               NET I/O               BLOCK I/O           PIDS
6a5d3352e67e        0.00%               5.52 MiB / 1.954 GiB   0.28%               1.179 GB / 815.4 MB   577.2 MB / 837 MB   0

CONTAINER           CPU %               MEM USAGE / LIMIT      MEM %               NET I/O               BLOCK I/O           PIDS
6a5d3352e67e        0.00%               5.52 MiB / 1.954 GiB   0.28%               1.179 GB / 815.4 MB   577.2 MB / 837 MB   0

On the server node, modify the name of the running rancher/server container to Xiandian_ After the query box and the answer box are filled in, the query results will be checked.

docker ps
docker rename ID xiandian_server
docker ps

At the server node, use the docker command to list all networks, and fill the above operation commands and inspection results into the answer box.

docker network ls

At the server node, use the docker command to query all the details of the bridge network, and fill the above operation commands and inspection results into the answer box.

docker network inspect bridge

On the server node, use the docker command to create a file named xd_net, the network segment is 192.168.3.0/24 and the gateway is 192.168.3.1. After creation, query the network list and fill the above operation commands and inspection results into the answer box.

docker network creat --subnet=192.168.3.0/24 --ip-range=192.168.182.3.0/24 --gateway=192.168.182.3.1 xd_net 
docker network inspect xd_net

On the server node, use the docker command to create a file named xd_net, the network segment is 192.168.3.0/24, and the gateway is 192.168.3.1. After creation, query the details of the network, and fill the above operation commands and inspection results into the answer box.

#docker network creat --sunet=192.168.3.0/24 --ip-range=192.168.182.3.0/24 --gateway=192.168.3.1 xd_net
#docker network inspect xd_net

On the server node, use the docker command to create a file named xd_net, the network segment is 192.168.3.0/24, the gateway is 192.168.3.1, the created image is centos:latest, the container name is centos, and the docker network is xd_net, query the network name used by the container and the operation status of the container, and fill the above operation commands and inspection results into the answer box.

#docker netowork creat --subnet=192.168.3.0/24 --ip-range=192.168.3.0/24 --gateway=192.168.3.1 xd_net
#docker run -itd --name centos --net=xd_net cnetos:latest
#docker inspect -f {{NetworkSettings.Networks}} centos
#docker ps 

server node, using the docker command to create a node named xd_net, the network segment is 192.168.3.0/24, the gateway is 192.168.3.1, the created image is centos:latest, the container name is centos, and the docker network is xd_net, query the container IP address after creation, and fill the above operation commands and inspection results into the answer box.

#docker network creat --subnet=192.168.3.0/24 --ip-range=192.168.3.0/24 --gateway=192.168.3.1 xd_net
#docker run -itd --name centos --net=xd_net centos:latest 
#docker inspect -f {{.Networks.xd_net.IPAddress}} centos

server node, using the docker command to create a node named xd_net, the network segment is 192.168.3.0/24, and the gateway is 192.168.3.1. After creation, query the network list, and then delete the docker network xd_net, query the docker network list after completion, and fill the above operation commands and inspection results into the answer box.

#docker network creat --subset=192.168.3.1/24 --ip-range=192.168.3.0/24 --gateway=192.168.3.1 xd_net
#docker network m xd_net
#docker network ls 

Server node, use the docker command to list only the port mapping status of the Ranger / server container, and fill the above operation commands and inspection results into the answer box.

docker port ID

On the server node, use the docker command to print the size and date of the Ranger / server image and the first ten pieces of historical update information. Fill the above operation commands and inspection results into the answer box.

docker history -H ID | head -10

server node, use the docker command to run centos image, run output and print "Hello world", and fill the above operation commands and inspection results into the answer box.

docker run centos:laetst /bin/echo "hello world"

On the server node, use the docker command to run centos image, run the output and print "Hello world". It is required to start the command to automatically delete this container and the generated data after printing. Fill the above operation commands and inspection results into the answer box.

docker run --rm centos:latest /bin/echo "hello world" 

Server node, use the docker command to set the yum source of the current operating system to local Copy the repo file to the / opt / directory in the Ranger / server container. After completion, use the exec command to query the list of all files in the / opt directory of the container, and fill the above operation commands and inspection results into the answer box.

#docker cp /etc/yum.repos.d/local.repo ID:/opt
#docker exec -it ID /bin/ls /opt/

At the server node, use docker to query the volume group information used by the current system, and fill the above operation commands and inspection results into the answer box.

docker volume ls 

On the server node, start the image with centos:latest to create a container. The container is mounted using XD_ Mount the volume group of volume to the root partition. After that, check the mounting status of the container through inspect, and fill the above operation commands and inspection results into the answer box.

#docker volume create --name=xd_volume 
#docker run -itd -v xd_volume:/root centos:laets
#docker ps -a
#docker inspect -f {{Host.Config.Binds}} ID 

Write the centos-7 image built in the above question as the basic image and build the HTTP service. Dockerfile requires to delete the yum source of the image, use the yum source file of the current system, and install the HTTP service after completion. This image requires to expose port 80. The name of the built image is http: v1 0 After completion, check the dockerfile file and the image list, and fill the above operation commands and inspection results into the answer box.

#cat Dockerfile
FROM 192.168.182.50:5000/centos-7
MAINTAINER xiandian
RUN rm -rf /etc/yum.repos.d/*
ADD local.repo /etc/yum.repos.d/
RUN yum install -y httpd
EXPOSE 80

#docker build -t 192.168.182.50:5000/httpd:v1.0
#docker images 

Write the centos-7 image built in the above question as the basic image and build the database service. Dockerfile requires to delete the yum source of the image, use the yum source file of the current system, install the mariadb service after completion, use the MySQL user to initialize the database and add MYSQL_USER=xiandian,MYSQL_PASS=xiandian environment variable, which requires the database to support Chinese, expose port 3306, and start the container to run mysld_safe command, after completion, start the created image and query the dockerfile file, enter the container to view the database list of the container, and fill the above operation commands and inspection results into the answer box.

#cat Dockerfile
FROM 192.168.182.50:5000/centos-7
MIANTAINER xiandian
RUN rm -rf /etc/yum.repos.d/
ADD loacl.repo /etc/yum.repo.d/
RUN yum install mariadb-server
RUN mysql_install_db --user=mysql
ENV LC_ALL en_US.UTF-8
ENV MYSQL_USER=xiandian
ENV MYSQL_PASS=xiandian
EXPORES 3306
CMD mysql_safe
#docker build -t 192.168.182.50:5000/centos-mariadb:v1.0
#docker images 

At the server node, query the system information of docker through docker api, and fill the above operation commands and inspection results into the answer box.

curl -X GET http://localhost:2375/info

Query the version of docker through docker api in the server node, and fill the above operation commands and inspection results into the answer box.

curl -X GET http://localhost:2375/version

On the server node, query all containers in docker through docker api, and fill the above operation commands and inspection results into the answer box.

curl -X GET http://localhost:2375/containers/json

On the server node, query all images in docker through docker api, and fill the above operation commands and inspection results into the answer box.

curl -X GET http://localhost:2375/images/json

At the server node, query the specific information of the rancher/server image through the relevant commands of the docker api, and fill the above operation commands and inspection results into the answer box.

curl -X GET http://localhost:2375/images/ID/json

According to the Tomcat image provided, create a container, use the image, create the / root/www1 directory, and write index. In the www1 directory JSP file, the default project address of the container is connected to the created www1 directory. When it is required to access tomcat, the output sentence is this is Tomcat1. Finally, start the container, start the Tomcat service, query the front page of Tomcat with curl command, and submit the operation command and return results to the answer box in the form of text.

#mkdri /root/www1
#vi index.jsp
<html>
<head>
<taile>tomcat</title>
</head>
<body>
this is tomcat
</body>
</html>
#docker run -itd -P -v /root/www1:/usr/local/tomcat/webapps/ROOT 192.168.182.50:5000/ tomcat:latest /bin/bash
#docker ps 
#docker exec -it ID /bin/bash
#cd /bin
#startup.sh
#exit
#curl  http://192.168.182.50: port

On the server node, use the docker command to view the IDs of the two recently created containers, and submit the operation command and return results to the answer box in text form.

docker ps -n 2 -q 

On the server node of the container, query the process number of the rancher/server container, establish the namespace / var/run/netns, connect with the rancher/server container, and query the ip of the container through the relevant commands of ip netns. Submit the operation command and return result to the answer box in text form.

1.docker ps | grep rancher
2.docker inspect -f {{.State.Pid}} container ID
3.mkdir /var/run/netns
4.ln -s /proc/Process number/ns/net  /var/run/netns/rancher-server
5.ip netns list
6.ip netns exec rancher-server ip a

Container storage configuration
On the container server node, use the mysql:8.0 image to create a container named mysqldb, use the image nginx:latest to create a container named nginxweb, connect the database in the nginxweb container to the mysqldb container, and use inspect -f to view the link. Submit the operation command and inspection results to the answer box in text form.

1.dokcer run -itd --name mysqldb -P mysql:8.0 /bin/bash
2.docker run -itd --name nginxweb -P --link mysqldb:db  nginx:latest /bin/bash
3.dokcer inspect -f {{.HostConfig.Links}} mysqlweb

Container synthesis
On the container server node, start a container named nginx with the provided nginx image, and the mapping port is 80:80; Then create a new index. In the / opt directory HTML file, add index The title Value in the HTML file is: "Welcome to XianDian!", The body value in the label: "this", "body!" The value of p tag is: "Thank you for using nginx!", Finally, use the command to index Put the HTML file into the default directory of nginx service, and query the nginx service through curl command. Submit the operation command and return result to the answer box in text form.

1.docker run -itd --name nginx -p 80:80 nginx:latest /bin/bash
2.mkdir /opt/index.html
3.vi index.html
        Welcome to XianDian!
        this is container!
        Thank you for using nginx!
4.docker exec -it container ID /bin/bash
5./usr/sbin/nginx((can also be omitted)
6.cd /usr/share/nginx/html
7.rm -rvf index.html
8.exit
9.docker cp /opt/index.html container ID:/usr/share/nginx/html/
10.curl -L 172.30.15.50

Container limit CPU
On the server node, use centos:latest image to create a container named xdtest, and explicitly limit the container's use of CPU resources to 0.25 seconds at most every 0.5 seconds. Submit the above operation commands and return results to the answer box in text form.

1.docker run -itd --name xdtest --cpu-period=500000 --cpu-quota=250000 centos:latest /bin/bash
2.docker exec -it container ID /bin/bash
3.cd /sys/fs/cgroup/cpu
4.ls
5.cat cpu.cfs_quota_us

Container limit block device I/O
On the server node, use the centos:latest image to create a container named blocklimit. After creation, enter the container and use the dd command to test the time spent writing 41MB of data. (dd if=/dev/zero of=testfile0 bs=8k count=5000 oflag=direct) then modify the corresponding Cgroup file to limit the speed of writing to the disk to 1024000 bytes. Finally, use the dd command to test the time spent writing 41MB to verify whether the I/O is limited. Submit the above operation commands and return results to the answer box in text form.

1.docker run -itd --name blocklimit centos:latest /bin/bash
2.docker exec -it container ID /bin/bash
3.dd if=/dev/zero of=testfile0 bs=8k count=5000 oflag=direct
cd /dev/mapper     ll      ll /dev/dm-4
4.echo "252:4 10240000" >
/sys/fs/cgroup/blkio/system.slice/docker-ae5a00693a19845879a0677c50db003195a2928311332336e8fa4ae3b506d13d.scope/blkio.throttle.write_bps_device  
5.docker exec -it container ID /bin/bash
7.dd if=/dev/zero of=testfile0 bs=8k count=5000 oflag=direct

Container image warehouse
On the server node, use the command to query the images in the private warehouse redistry. Submit the operation command and return result to the answer box in text form.

curl http://192.168.182.50:5000/v2/_catalog

Container underlying service
On the server node, use nginx image to create a container named 1daoyun. Only 0 kernel can be used. Nginx: latest is used for the image. Check the kernel usage by viewing the Cgroup related files, and fill the above operation commands and inspection results in the answer box.

1.docker run -itd --name 1daoyum --cpuset-cpus=0 nginx:latest /bin/bash    
2.cat /sys/fs/cgroup/cpuset/system.slice/docker-1cedb30724b0e67d32662673e04abc6d82aa1f2346bfa6240bd3ed604780d564.scope/cpuset.cpus

Container storage configuration
(1) Run the mysql:8.0 image on the container server node and set the database password to xd_root, map port 13306 of the server node to port 3306 of the container;
(2) Enter the container and create a container named xd_db, create a database named xiandian and password xd_pass user, set this user to xd_db database has all permissions and allows this user to access remotely;
(3) Use xiandian users to log in to the database remotely and query the list of databases in the database.
Submit the operation command and return results to the answer box in text form.

1.docker run -itdP -e MYSQL_ROOT_PASSWORD=xd_root -p 13306:3306 mysql:8.0 
2.docker exec -it ID /bin/bash
3.mysql -uroot -pxd_root
4.create database xd_db
5.grant all privileges on xd_db.* to 'xiandian'@'%' identified by 'xd_pass';
6.exit
7.Enter container
8.ip a
9.mysql -uxiandian -pxd_pass -hIP  -e "show database;"

Container synthesis
(1) On the server node of the container, create the / root/www1 directory, and write the index in the www1 directory JSP file; (2) Use the Tomcat image to create a container. The default project address of the container is connected to the / root/www1 directory. When it is required to access tomcat, the output statement is "this is Tomcat1";
(3) Enter the container, start the tomcat service, and use the curl command to query the front page of tomcat.
Submit the operation command and return results to the answer box in text form.

1.mkdir /root/www1
2.vi index.jsp
        <html>
    <head>
           <title>Tomcat1</title>
    </head>
    <body>
           this is Tomcat1

    </body>
</html>

3.docker run -itd -P -h tomcatl -v /root/www1:/usr/local/tomcat/webapps/ROOT 192.168.182.50:5000/tomcat:latest /bin/bash
4.docker ps (Check the one in front of the mapping port)
5.curl http://192.168.182.50: mapping port

Container construction
On the container server node, use the supermin5 command (if the command does not exist, install it yourself) to build a docker image of CentOS 7 system named centos-7. The image is preloaded with yum, net tools, initscripts and vi commands. After the construction is completed, submit the image to the container warehouse and view the image. Submit the operation command and return results to the answer box in text form.

1.yum install -y supermin5 
2.supermin5 -v --prepare base yum net-tools initscripts vi coreutils -o supermin.d
-v Activate the debugging message and you can see the operation information
--prepare prepare supermin Required tools
base,coreutils Is the tool needed, if used yum Need to add yum command
-o Set an output directory
supermin.d Output directory name
3.supermin5 -v --build --format chroot supermin.d -o appliance.d/
--build Build the tools you need
--format chroot Set output format
4.echo 7 > appliance.d/etc/yum/vars/releasever
 Set the system version number so that docker The image can get normal operation.
5.tar --numeric-owner -cpf centos-7.tar -C appliance.d .
encapsulation docker Mirror files to archive files
6.cat centos-7.tar | docker import - 192.168.182.50:5000/centos-7
 Import tar Archive files to docker In the image list for easy operation
7.docker images centos-7

Written by Dockerfile
Based on the centos-7 image built in the above question, build the database image CentOS MariaDB: v1 0, the requirements are:
(1) Delete the local Yum source of the image and use the yum source file of the container server node;
(2) Install mariadb service and use mysql user to initialize the database;
(3) Set MYSQL_USER=xiandian,MYSQL_PASS=xiandian environment variable;
(4) The database supports Chinese;
(5) Exposed 3306 ports;
(6) When mysld container can run automatically_ Safe command.
Use the cat command to view the Dockerfile file and build the image. Submit the operation command and return results to the answer box in text form.

1.mkdri mydockerfile
2.vi Dockerfile
FORM 192.168.182.50:5000/centos-7
MAINTAINER xiandian
RUN rm -fv /etc/yum.repos.d/*
ADD laod.repo /etc/yum.repos.d/
RUN yum install mariadb-server
RUN mysql_install_db --user-mysql
ENV LC_ALL en_us.utf-8
ENV MYSQL_USER xiandian
ENV MYSQL_PASS xiandian
EXPOSE 3306
CMD mysql_safe
3.cp /etc/yum.repos.d/docker.repo /root/mydockerfile
4.docker build -t 192.168.182.50:5000/centos-mariadb:v1.0 .
5.docker images | grep centos-mariadb

Vessel expansion
On the server node, use centos:latest image to create a container named xiandian, then expand the volume space value of the container xiandian to 20G (file system expansion is not required), and finally view the volume space value of the container. Submit the above operation commands and return results to the answer box in text form.
Reference answer

[root@server mapper]# docker run -itd 172.30.11.4:5000/centos:latest /usr/sbin/init 
6dcba06250667a7a88c0051fdf264e790ed9248d7fa0e62d837e1d6bd1276715
[root@server mapper]# dmsetup table
docker-253:1-142606574-73a6b22361ccddf9e2ffeb3f64ca0723284816c4415c7e4045fd604f706e8219: 0 20971520 thin 252:0 146
docker-253:1-142606574-pool: 0 209715200 thin-pool 7:1 7:0 128 32768 1 skip_block_zeroing 
docker-253:1-142606574-64319762341c389d84ea8aa8cb8e280229be30e2a3a2a21bce7b26452e75c7b8: 0 20971520 thin 252:0 37
docker-253:1-142606574-be33475fb10c6de25f98dd5adb29f0ca1fada08366a4eb568d61afcf3cc619da: 0 20971520 thin 252:0 150
docker-253:1-142606574-94af7194245e03485a51e6ac1b45fb8f1f90a2fa906ab3c03a267ea0256858dc: 0 20971520 thin 252:0 8
docker-253:1-142606574-be12a48427d3c06a81c6e5663a4d360a7f1cebe51b8a027b82a49eddfda70710: 0 20971520 thin 252:0 148
[root@server mapper]# echo $((20*1024*1024*1024/512))
41943040
[root@server mapper]# echo 0 41943040 thin 252:0 150 | dmsetup load docker-253:1-142606574-be33475fb10c6de25f98dd5adb29f0ca1fada08366a4eb568d61afcf3cc619da
[root@server mapper]# dmsetup resume docker-253:1-142606574-be33475fb10c6de25f98dd5adb29f0ca1fada08366a4eb568d61afcf3cc619da
[root@server mapper]# dmsetup table /dev/mapper/docker-253:1-142606574-be33475fb10c6de25f98dd5adb29f0ca1fada08366a4eb568d61afcf3cc619da
0 41943040 thin 252:0 150

Topics: Docker