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
Table of contents 1. The default focus is on the ...
Only display Docker container mount directory inf...
This article example shares the specific code of ...
concept If the index contains all the data that m...
Through the study and application of Node, we kno...
There is another tree structure Javascript object...
In the previous article https://www.jb51.net/arti...
This is the first time I used the CentOS7 system ...
In the vertical direction, you can set the row al...
SQL statement /* Some methods of eliminating dupl...
Table of contents Preface Prepare Summarize n way...
1. Links Hypertext links are very important in HTM...
I was recently working on a project about face co...
Introduction Describes the use cases and solution...
Getting Started with Data Volumes In the previous...