Operation of the two common docker: unresolved docker firewalld disposed within the dns etc.

First, how to start a exited the container?

[root@localhost ~]# docker start storage4

 

Description: architecture forests is a focus on architecture blog, address: https://www.cnblogs.com/architectforest

         The corresponding source code can be accessed here for:  https://github.com/liuhongdi/

 Description: Author: Liu association E-mail: [email protected]

 

Second, the docker container running state is exited (0)?

run overtime parameters -d -i -t

  • -i: Run vessel in interactive mode, typically used in conjunction with -t;

  • -t: reassign a pseudo input terminal into a container, normally used in conjunction with -i;

example:

[root@localhost ~]# docker run --name tracker1 --privileged -d -i -t 470671670cac
5a674df0c4bf9fa47d548e85b77166bc3b7ee4c7905a394ae8426e278cda5cce

View state, not the exit

[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
5a674df0c4bf        470671670cac        "/bin/bash"         9 seconds ago       Up 8 seconds                            tracker1

 

Third, how docker container in the boot centos systemctl available?

 

[root@5a674df0c4bf /]# systemctl status 
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
[root@localhost
~]# docker run --name tracker1 --privileged -d -i -t 470671670cac /usr/sbin/init 0882a60ec13999b7fff728468fc1b9d89c47d05db49bac635d03b4a2e87c2a6d
[root@0882a60ec139
/]# systemctl start sshd Failed to start sshd.service: Unit sshd.service not found.

 

Description: no longer reported Failed to connect to bus: Host is down

Description: / usr / sbin / init: the initial container CENTOS, for starting dbus-daemon.

 

Four, docker how to generate a new image

Commit command

After making modifications in the container, directly commit

[root@914e7dcb1298 fdfs]# exit
exit

[root@localhost liuhongdi]# docker commit 914e7dcb1298 fastdfs_storage_0.1

 

Description:

914e7dcb1298: id container

fastdfs_storage_0.1: from the name to imae

You can see the image of the list had been generated by the image of our

[root@localhost liuhongdi]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
fastdfs_storage_0.1   latest              fc81a26e998e        8 seconds ago       533MB
centos                latest              470671670cac        6 weeks ago         237MB

 

Five, docker how to mount a local directory?

-v parameter, a colon ":" in front of the host directory is a directory, follow the directory within the directory container

Caveats: 1, the path you want to use an absolute path, avoid using a relative path error

2, if the modifications in the container from the mount into the host directory / file owner,

     Will affect the directory on the host / file owner,

     Because the files under linux is to use uid to correspond, so try not to do this kind of modification

example:

[root@localhost liuhongdi]# docker run --name tracker1 --privileged -v /usr/local/source:/usr/local/source -d -i -t 470671670cac /usr/sbin/init
6351748e4916dc0300cdb663fe14187da78d7cd16d130c3f2b67a11c1f772aa9

[root@localhost liuhongdi]# docker exec -it tracker1 /bin/bash
[root@6351748e4916
/]# ls /usr/local/source/ V1.0.43.tar.gz apache-zookeeper-3.5.6-bin.tar.gz jmeter.log nginx-1.17.8

 

Description: After entering the container before you can see the file in the host machine

 

Six, can not be resolved within the docker dns,

      Needs to be done is set to host the firewall:

Production environment is absolutely not disable the firewall, just open IP masquerading functionality that is working properly dns

 

[root@localhost liuhongdi]# firewall-cmd --zone=public --add-masquerade --permanent
success
[root@localhost liuhongdi]# firewall-cmd --reload
success
[root@localhost liuhongdi]# systemctl stop firewalld
[root@localhost liuhongdi]# systemctl start firewalld
[root@localhost liuhongdi]# systemctl stop docker
[root@localhost liuhongdi]# systemctl start docker
[root@localhost liuhongdi]# docker run --name tracker1 --privileged -v /usr/local/source:/usr/local/source -d -i -t 470671670cac /usr/sbin/init
914e7dcb12983cc27302a7becf05833abab07d8a765bf11326ca0c9ecfa12e6a
[root@localhost liuhongdi]# docker exec -it tracker1 /bin/bash
[root@914e7dcb1298 /]# ping www.sina.com.cn
PING spool.grid.sinaedge.com (120.192.83.125) 56(84) bytes of data.
64 bytes from 120.192.83.125 (120.192.83.125): icmp_seq=1 ttl=51 time=34.6 ms

^C
--- spool.grid.sinaedge.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 5ms
rtt min/avg/max/mdev = 20.664/27.730/34.566/5.679 ms

 

Guess you like

Origin www.cnblogs.com/architectforest/p/12389218.html