網頁

2015年8月30日 星期日

Docker 1.7.1 --- How to enable Non-root Users to run Docker command

Since Docker version 0.5.3, the docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can access it with sudo.
If you would like to use Docker as a non-root user, you should now consider adding your user to the "docker" group because the docker group is equivalent to the root user.

To create the docker group and add a user or users to by using the sudo usermod -aG docker davidwa command.
To remember that you will have to log out and log back in to ensure this user is running with the correct permissions.

To verify its mechanism works by running docker with sudo as follows:
So do that we can execute Docker command without root right now.

Docker 1.7.1 --- How to change hostname on Docker Container in Ubuntu/Lubuntu 15.04

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:

Since 2010 Design by Davidwa
©Copyright Davidwa Inc. All rights reserved.