Detailed process of modifying hostname after Docker creates a container

Detailed process of modifying hostname after Docker creates a container

There is a medicine for regret in the world, as long as you are willing to think about it! No more recreating containers!

I have a container called m2 and now I want to change its hostname

insert image description here

1. Check the location of the container configuration file on the host machine. Here we see /var/lib/docker/containers/67e012c02434168aff3762ab4edf7550f0bfe1db57b396ce78660f140dd3056e

insert image description here

2. Shut down the container and shut down the docker service prerequisites, which is very important! ! ! Prerequisites are very important! ! ! Prerequisites are very important! ! !

insert image description here

3. Enter the host folder where the configuration file of the container is located, search for the original hostname, and you can see that we need to modify three places, the files are config.v2.json, hostname, hosts

insert image description here

4. Make a backup before modifying

insert image description here

5. Modify these 3 places

insert image description here

insert image description hereinsert image description here

6. Start the docker service, start the container, and check the hostname

insert image description here

hostname modified successfully! Are you surprised? ! !

This concludes this article on the detailed process of modifying the hostname after Docker creates a container. For more information about modifying the hostname of a Docker container, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to the problem of not being able to obtain the hostname of the host in the docker container
  • Directory permissions when creating a container with Docker
  • Simple steps to create a MySQL container with Docker
  • Detailed explanation of creating a MySQL container with Docker and connecting to the container through the command line
  • How to create a MySQL container with Docker

<<:  MySQL multi-instance installation boot auto-start service configuration process

>>:  About the role of meta in HTML (collected and sorted from the Internet)

Recommend

A comprehensive analysis of what Nginx can do

Preface This article only focuses on what Nginx c...

Basic installation tutorial of mysql decompression package

Since I have changed to a new computer, all the e...

Discussion on more reasonable creation rules for MySQL string indexes

Preface Regarding the use of MySQL indexes, we ha...

WeChat applet implements text scrolling

This article example shares the specific code for...

How to manually scroll logs in Linux system

Log rotation is a very common function on Linux s...

Three ways to prevent MySQL from inserting duplicate data

Create a new table CREATE TABLE `person` ( `id` i...

How to automatically delete records before a specified time in Mysql

About Event: MySQL 5.1 began to introduce the con...

JavaScript MouseEvent Case Study

MouseEvent When the mouse performs a certain oper...

ReactJs Basics Tutorial - Essential Edition

Table of contents 1. Introduction to ReactJS 2. U...

How to configure ssh to log in to Linux using git bash

1. First, generate the public key and private key...

CocosCreator Skeleton Animation Dragon Bones

CocosCreator version 2.3.4 Dragon bone animation ...

Detailed explanation of rpm installation in mysql

View installation and uninstallation # View rpm -...

Common Linux English Error Chinese Translation (Newbies Must Know)

1.command not found command not found 2. No such ...

Nginx source code compilation and installation process record

The installation of the rpm package is relatively...

How to install JDK 13 in Linux environment using compressed package

What is JDK? Well, if you don't know this que...