Docker container cannot connect to the Docker daemon. Is the Docker daemon running in this host? workaround.

Source: Internet
Author: User
Tags docker ps

Linux version: Ubuntu16.04

The first time you install Docker, it is possible to run the Docker command, such as

Docker PS

After restarting the system, the following error occurred after running Docker PS: Cannot connect to the Docker daemon. Is the Docker daemon running to this host? After finding the data, you know that this is a permission issue. The root user is required to run.

The daemon that Docker starts from 0.5.2 always runs as root. The Docker daemon is bound to a UNIX socket instead of a TCP port. The UNIX socket defaults to the root user, so you must add sudo when using Docker.

Start with 0.5.3, create a group called Docker, and then add users to the group. When the Docker daemon is started, it assigns Unix read and write permissions to the Docker group. In this way, you don't have to use sudo when you use the Docker client as a user in the Docker group.
----Split Line---The following is the solution: the first: Run the following command sequentially, and jump to the root user to run the Docker command:

sudo su                       //switch to root
service Docker start//      start Docker service
Docker images              //Show all images
Docker PS//Rerun Docker command
The second: Add the current user to the Docker user group: # Adding Docker user groups
sudo groupadd Docker

# Add yourself to the Docker user group
sudo gpasswd-a myusername Docker

# Restart Docker background service
sudo service docker restart

Reboot the system and run the Docker command directly, without sudo.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.