1.The three files /etc/hosts, /etc/resolv.conf and /etc/hostname in the container do not exist in the image, but exist in /var/lib/docker/containers/. When starting the container, these files are mounted into the container in the form of mount. Therefore, if these files are modified in the container, the modified parts will not exist in the top layer of the container, but will be written directly to these three physical files. 2. Why does the modified content disappear after restart?The reason is: every time Docker starts a container, it rebuilds a new /etc/hosts file. Why is this? The reason is: the container is restarted, the IP address is changed, and the original IP address in the hosts file is invalid. Therefore, the hosts file should be modified, otherwise dirty data will be generated. 3. Is there any good solution?You can use the --add-host parameter of the docker run command to add a mapping between host and ip for the container. Supplement: Solve the problem that the restart configuration does not take effect in the Docker container (source /etc/profile) Problem description:When using Docker, you may need to customize some configuration files in the container instance, such as /etc/profile. However, after the modification, you need to manually source it every time you start the container to make it effective again, which is very cumbersome. Solution:In the container instance, add source /etc/profile to the end of the ~/.bashrc configuration file, save the file and exit. This will allow the configuration file to be automatically refreshed after restart without manual operation. The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: Example code for implementing image adaptive container with CSS
>>: Web page creation basic declaration document type description (DTD
1. WebDesignerWall 2. Veerle's Blog 3. Tutori...
To be honest, this question involves a lot of cor...
In the Linux system, there is a kind of file call...
When setting display:flex, justify-content: space...
Written in front No matter how well the code is w...
1. Download the ubuntu16.04 image and the corresp...
Export a single table mysqldump -u user -p dbname...
There are two ways to run .sh files in Linux syst...
Install Enter the following command to install it...
Table of contents Configuration parsing Service C...
Table of contents Foreign Key How to determine ta...
Preface This article summarizes some implementati...
The solution to the transparent font problem after...
1. Make sure the system has the required libaio s...
<br />How can I remove the scroll bar on the...