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
Find the problem Today at work, when copying tabl...
mysql row to column, column to row The sentence i...
1. System installation package yum -y install mak...
Table of contents Overview Example 1) Freeze Obje...
introduction Xiao A was writing code, and DBA Xia...
1. Insert the wireless network card and use the c...
Overview In zabbix version 5.0 and above, a new f...
background As the number of application systems c...
This article uses examples to illustrate the use ...
1. Download MySQL database and install and config...
1. mysqlbinlog: [ERROR] unknown variable 'def...
Table of contents 1. Required attributes 1. name ...
The ogg process of a database produced some time ...
Table of contents Preface What are enums in TypeS...
Download the latest version of MySQL for Ubuntu L...