In general, we do any changes in a container and the result is not permanent. That is, if we log out and attach to it again, all changes will be lost so that get back the initial container.
Of course, we can avoid this problem by using the docker commit command so that the changes will be made permanent.
If we want to change hostname on one container, whether there is a alternative method to do it.
Yes, we can directly edit config.json to adjust some parameter!
How to do it?
At first, we need to check the running container status by using the sudo docker ps | head command
To stop a container by using the sudo docker stop command
To stop Docker service by using the sudo service docker stop command
To edit config.json in the /var/lib/docker/containers// directory
and replace “Hostname”:” ” with “Hostname”:” ”
AS-IS:
TO-BE:
To start Docker service by using the sudo service docker start command
To start a container by using the sudo docker start command
So does that the hostname on Docker container has already been changed now.
AS-IS:
TO-BE:
沒有留言:
張貼留言