“This is the seventh day of my participation in the August More Text Challenge. For details, see: August More Text Challenge.”

1. Docker configuration path

1.1 Storage Location

You can use the docker system info | grep “Root Dir” to view the current use of storage location.

Local resources related to Docker are stored in the /var/lib/docker/directory by default. Take the AUfs file system as an example, where:

  • containerDirectory to store container information
  • graphDirectory for storing image information
  • aufsThe specific image layer file is stored in the directory

1.2 Configuration File

For systems using Systemd (e.g. Ubuntu 16.04, Centos 7/8, etc.), the configuration file is in /etc/docker/daemon.json

Daemon.json is docker’s detailed configuration file and generally does not need to be modified

2. Enable Docker debugging mode

Add to the docker configuration file daemon.json

{
  "debug": true
}
Copy the code

Restart the daemon process

Method 1

sudo systemctl daemon-reload
sudo systemctl restart docker
Copy the code

Method 2

$ sudo kill -SIGHUP $(pidof dockerd)
Copy the code

According to the log information printed by the console, once the execution is successful, the Docker debugging mode is enabled

3. Mirror debugging

When building a mirror, it is common to encounter the problem that the mirror build fails. At this point, you can only find the problem of the image build script Dockefile by means of image debugging, as shown in the following figure:

The /bin/sh: /bin/bash: not found error occurs during Step 3. You can perform the following steps to resolve the problem:

1. Enter the temporary image that was built successfully before

Enter the temporary image 22d31CC52b3e obtained in the previous successful instruction as shown in the figure above

Docker run-it 22d31CC52b3e creates and starts a container for temporary images

2, manual execution instructions

Once inside the temporarily mirrored container, find the cause of the mirror compile error by entering the next instruction that needs to be called.

That is, manually perform the execution required in Step 3 to discover the problem and find a solution. If step 3 is successfully executed, the restoration is successful. Then modify the Dockerfile and rebuild the image

4 Container Debugging

The log

$docker logs [container name]# View N line log$docker logs -n 100Copy the code

Attach checks STDout in real time

$ docker attach CONTAINER 
Copy the code

By default, stdin, the proxy signals, is bound

If you ctrl-C the container will usually exit. A lot of times you don’t want to, you just want to separate, you can ctrl-P ctrl-Q.