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.