I would like to use this image https://hub.docker.com/_/amazonlinux to script my EC2 machine
Here is my Dockefile :
FROM amazonlinux:2
MAINTAINER "xxxxx" <xxxxx#xxxx.xx>
RUN yum -y update
RUN yum -y install httpd
WORKDIR /var/www/html
CMD [ "/usr/sbin/httpd","-D","FOREGROUND" ]
systemctl do not works :
bash-4.2# systemctl list-units
Failed to get D-Bus connection: Operation not permitted
bash-4.2# systemctl status httpd.service
Failed to get D-Bus connection: Operation not permitted
I cannot restart
bash-4.2# systemctl restart httpd.service
Failed to get D-Bus connection: Operation not permitted
/etc/os-release
bash-4.2# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
No problem on real ec2 :
[ec2-user#ip-xxxxxxxxx]$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
[ec2-user#ip-xxxxxxxxx]$ systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since mer. 2020-05-20 16:36:19 UTC; 1h 50min ago
Docs: man:httpd.service(8)
Main PID: 3047 (httpd)
Status: "Total requests: 7; Idle/Busy workers 100/0;Requests/sec: 0.00106; Bytes served/sec: 20 B/sec"
CGroup: /system.slice/httpd.service
├─3047 /usr/sbin/httpd -DFOREGROUND
├─3075 /usr/sbin/httpd -DFOREGROUND
├─3076 /usr/sbin/httpd -DFOREGROUND
├─3077 /usr/sbin/httpd -DFOREGROUND
├─3078 /usr/sbin/httpd -DFOREGROUND
├─3079 /usr/sbin/httpd -DFOREGROUND
└─3495 /usr/sbin/httpd -DFOREGROUND
mai 20 16:36:19 xxxxxxxxx.internal systemd[1]: Starting The Apache HTTP Server...
mai 20 16:36:19 xxxxxxxxx.internal systemd[1]: Started The Apache HTTP Server.
It's a famous image, has anyone found a solution ?
The "httpd" is run as PID-1 of the container.
If you do "docker stop (container)" then httpd will get a SIGTERM. If you do "docker restart (container)" then it will cycle through docker-stop / docker-start also recreating the httpd daemon.
https://docs.docker.com/engine/reference/commandline/restart/
Using systemd in a container is not needed here. If you really want to do that then there are multiple options. It could be to run a full systemd in a container or to use another service manager instead.
https://github.com/gdraheim/docker-systemctl-images/blob/master/centos-httpd.dockerfile
Related
I am trying to build a docker environment through docker-compose, however it gives errors.
$ docker-compose build
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
Docker daemon is running
$ sudo systemctl status docker
[sudo] password for mansop:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-02-19 12:07:27 AEDT; 22min ago
Docs: http://docs.docker.com
Main PID: 8972 (dockerd-current)
Tasks: 22
Memory: 22.8M
CGroup: /system.slice/docker.service
├─8972 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/l...
└─8978 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containe...
Docker installed from centos7 repository:
$ docker --version
Docker version 1.13.1, build 4ef4b30/1.13.1
I tried setting up DOCKER_HOST following the error message but the issue persists:
$ echo $DOCKER_HOST
127.0.0.1:2375
Any thoughts?
For some reason there were no docker group in my system, my user was not part of docker group and the docker socket file was not under the docker group.
The commands below fixed my issue:
sudo useradd docker
usermod aG docker mansop
sudo chown root:docker /var/run/docker.sock
I am trying to install docker on an Ubuntu-16.04 server.
When I execute sudo apt-get install -y docker-ce the system tells me that docker is already installed:
$ sudo apt-get install -y docker-ce
Reading package lists... Done
Building dependency tree
Reading state information... Done
docker-ce is already the newest version (5:19.03.1~3-0~ubuntu-xenial).
0 upgraded, 0 newly installed, 0 to remove and 133 not upgraded.
And running sudo systemctl status docker looks like it's already running:
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-08-21 17:26:02 PDT; 24min ago
Docs: http://docs.docker.com
Main PID: 14283 (dockerd)
Tasks: 28
Memory: 64.7M
CPU: 1.128s
CGroup: /system.slice/docker.service
└─14283 /usr/bin/dockerd
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.137366865-07:00" level=warning msg="Your kernel does not support cgroup rt period"
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.137381329-07:00" level=warning msg="Your kernel does not support cgroup rt runtime"
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.139558576-07:00" level=info msg="Loading containers: start."
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.229011852-07:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.264094521-07:00" level=info msg="Loading containers: done."
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.317824839-07:00" level=warning msg="Not using native diff for overlay2, this may cause degraded performance for building images: opaque flag erroneously copied up, consider u
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.318092298-07:00" level=info msg="Docker daemon" commit=74b1e89e8a graphdriver(s)=overlay2 version=19.03.1
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.318144708-07:00" level=info msg="Daemon has completed initialization"
Aug 21 17:26:02 node1 dockerd[14283]: time="2019-08-21T17:26:02.333727950-07:00" level=info msg="API listen on /var/run/docker.sock"
Aug 21 17:26:02 node1 systemd[1]: Started Docker Application Container Engine.
But when I try to run docker-ps I get this error:
$ docker ps
The program 'docker' is currently not installed. You can install it by typing:
sudo apt install docker.io
Also which docker doesn't return anything...
Any idea of what can be going on here? How can I debug this further?
Thanks in advance
UPDATE
docker-cli appears to be installed to:
sudo apt-get install docker-ce-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
docker-ce-cli is already the newest version (5:19.03.1~3-0~ubuntu-xenial).
0 upgraded, 0 newly installed, 0 to remove and 133 not upgraded.
cord#node1:~$ which docker
But still the docker command is not there.
Here is the output of dpkg -L docker-ce:
$ dpkg -L docker-ce
/.
/etc
/etc/default
/etc/default/docker
/etc/init.d
/etc/init.d/docker
/etc/init
/etc/init/docker.conf
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/docker.socket
/lib/systemd/system/docker.service
/usr
/usr/bin
/usr/bin/dockerd
/usr/bin/docker-init
/usr/bin/docker-proxy
/usr/share
/usr/share/doc
/usr/share/doc/docker-ce
/usr/share/doc/docker-ce/changelog.Debian.gz
/usr/share/doc/docker-ce/README.md
/var
/var/lib
/var/lib/docker-engine
/var/lib/docker-engine/distribution_based_engine.json
I guess the install of your docker not complete for some reason or your steps not correct not sure.
What I suggest is next:
Step1: Remove the old install
$ apt-get purge docker-ce
Step2: Install docker using convenience script
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
If above still can not work, you can just use a prebuilt binary for docker client, see this:
Downloads your neede version from https://download.docker.com/linux/static/stable/x86_64/
Untar the downloaded package to get the docker binary, tar xzvf /path/to/<FILE>.tar.gz
Copy one binary with the name docker to /usr/bin, something like sudo cp docker/docker /usr/bin/
With above you have docker client ready in your system.
You have to install the docker-ce-cli package. The docker-ce package only contains the daemon.
$ dpkg -L docker-ce
...
/usr/bin/dockerd
/usr/bin/docker-init
/usr/bin/docker-proxy
...
The official documentation for installation on Ubuntu does not mention this directly, but the installation step includes docker-ce-cli:
sudo apt-get install docker-ce docker-ce-cli containerd.io
I have the following Dockerfile:
FROM ubuntu
ENV NPM_CONFIG_LOGLEVEL warn
ENV admin_user="PeerAdmin" network_name=$1 version=$2 hversion=hlfv1 fabrik_path=/fabric-tools project_dir=$(pwd)
ENV card_store_dir=$project_dir/.card-store stage_dir=$project_dir/.stage env_dir=$project_dir/env is_ok=1 FABRIC_VERSION=hlfv1
WORKDIR /app
COPY . /app
USER root
# RUN chown -R ubuntu:ubuntu .
WORKDIR /app
RUN apt-get update && \
mkdir "$fabrik_path" && \
cd "$fabrik_path" && \
export FABRIC_VERSION=hlfv1 && \
apt-get -y install apt-transport-https ca-certificates curl software-properties-common && \
apt-get -y install curl && \
apt-get -y install unzip && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
apt-get -y install docker.io && \
curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip && \
unzip fabric-dev-servers.zip && \
service docker start && \
./downloadFabric.sh && \
./startFabric.sh
Attempting to execute it, I am receiving an error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Commands like service docker start or systemctl do not work.
Try this cmd:
sudo service docker restart
You can't (*) run Docker inside Docker containers or images. You can't (*) start background services inside a Dockerfile. As you say, commands like systemctl and service don't (*) work inside Docker anywhere. And in any case you can't use any host-system resources, including the host's Docker socket, from anywhere in a Dockerfile.
You need to redesign this Dockerfile so that it only installs the software and makes no attempt to start it. Ideally a container would start only a single server, and would run it in the foreground as its CMD; otherwise you might depend on things like supervisord to have multiple servers if you must. If your application heavily relies on being able to start things in Docker, you might find it much easier to install in a virtual machine.
(*) Technically there are ways to do all of these things, but they're all tricky and complicated and have implications (up to potentially giving your container unrestricted root access over the host, and your container startup actively reconfiguring some low-level host details).
Launch the Terminal and execute the commands below:
$ sudo service --status-all
$ sudo service docker start
https://appuals.com/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock/
Solution 4: Start Docker with the Service command
1. Check the docker.service
sudo systemctl status docker
output is something like this:
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/docker.service.d
└─http-proxy.conf
Active: active (running) since Sat 2021-12-04 19:11:03 +0330; 2min 59s ago
Docs: https://docs.docker.com
Main PID: 28223 (dockerd)
Tasks: 29
CGroup: /system.slice/docker.service
└─28223 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.813464635+03:30" level=info msg="New memberlist node - Node:elitedesk will use memberlist nodeID:57d6b077dc1b with config:&{NodeID:57d6b077dc1b Hostname:elitedesk BindAddr:0.0.0.0 AdvertiseAddr:192.168.1.45 BindPort:0 Keys:[[214 188 67 83 106 206 215 54 212 222 237 172 208 101 235 219] [232 26 246 100 135 196 113 220 147 95 50 132 140 206 7 126] [236 55 254 140 107 62 111 184 64 103 33 77 246 154 26 50]] PacketBufferSize:1400 reapEntryInterval:1800000000000 reapNetworkInterval:1825000000000 StatsPrintPeriod:5m0s HealthPrintPeriod:1m0s}"
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.813277123+03:30" level=info msg="Daemon has completed initialization"
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.813269814+03:30" level=info msg="initialized VXLAN UDP port to 4789 "
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.814239176+03:30" level=info msg="Node 57d6b077dc1b/192.168.1.45, joined gossip cluster"
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.814424565+03:30" level=info msg="Node 57d6b077dc1b/192.168.1.45, added to nodes list"
Dec 04 19:11:03 elitedesk systemd[1]: Started Docker Application Container Engine.
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.891119330+03:30" level=info msg="API listen on /var/run/docker.sock"
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.964000220+03:30" level=error msg="error reading the kernel parameter net.ipv4.vs.conn_reuse_mode" error="open /proc/sys/net/ipv4/vs/conn_reuse_mode: no such file or directory"
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.964029536+03:30" level=error msg="error reading the kernel parameter net.ipv4.vs.expire_nodest_conn" error="open /proc/sys/net/ipv4/vs/expire_nodest_conn: no such file or directory"
Dec 04 19:11:03 elitedesk dockerd[28223]: time="2021-12-04T19:11:03.964042003+03:30" level=error msg="error reading the kernel parameter net.ipv4.vs.expire_quiescent_template" error="open /proc/sys/net/ipv4/vs/expire_quiescent_template: no such file or directory"
If seemed to have an error, restart it:
sudo systemctl restart docker
And check the status again. If did not solve, next
2. Request to the daemon's socket, see if it is up:
curl --unix-socket /var/run/docker.sock http://localhost/_ping; echo
Output is just OK message
OK
If did not get OK and got something like this:
curl: (7) Couldn't connect to server
3. Check the socket service
sudo systemctl status docker.socket
And a fine output will be:
● docker.socket - Docker Socket for the API
Loaded: loaded (/lib/systemd/system/docker.socket; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-12-04 19:10:57 +0330; 6min ago
Listen: /var/run/docker.sock (Stream)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/docker.socket
Dec 04 19:10:57 elitedesk systemd[1]: Starting Docker Socket for the API.
Dec 04 19:10:57 elitedesk systemd[1]: Listening on Docker Socket for the API.
And restart it even if it looked good. Because after stopping the daemon and start it again, it does not work and we should (as long as I know) restart docker.socket.
sudo systemctl restart docker.socket
Yet you were not able to fix it? next:
4. Run the daemon directly in debug mode
sudo dockerd -D -l debug
I had this same issue, run this command in your terminal. This fixed the problem.
sudo apt-get install docker-ce docker-ce-cli containerd.io
The error may come from "service docker start". If you want to follow the installation instructions from the upstream vendor for a docker container then you need to prepare the environment for that. I can run these commands easily by using the dockers-systemctl-replacement script.
It might be the case that the user with which you have logged in to docker engine is not having the correct permission. You can add the user to docker group with below command:
sudo usermod -a -G docker $USER
$USER is the username of the currently logged in user.
if you install docker with deb files, probably not install docker cli. So after install docker, install docker cli, #Jayanth's answer
I have installed Docker with yum install docker:
$ uname -a
Linux caspgval4 3.10.0-229.20.1.el7.x86_64 #1 SMP Wed Nov 4 10:08:36 CST 2015 x86_64 x86_64 x86_64 GNU/Linux
$ docker --version
Docker version 1.12.6, build 3a094bd/1.12.6
$ docker info
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: http://docs.docker.com
I am trying to install and run Docker, but it is giving an error as below:
$ sudo service docker start
Redirecting to /bin/systemctl start docker.service
Failed to start docker.service: Unit not found.
How do I resolve this issue? I tried the following commands, but no luck:
$ sudo systemctl start docker
Failed to start docker.service: Unit not found.
Extra information:
$ journalctl -u docker
No journal files were found.
-- No entries --
$ cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=rhel-push-plugin.socket
Requires=docker-cleanup.timer
[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--authorization-plugin=rhel-push-plugin \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
MountFlags=slave
[Install]
WantedBy=multi-user.target
I tried the following:
$ sudo systemctl daemon-reload
$ sudo systemctl start docker
Failed to start docker.service: Unit not found.
$ sudo journalctl -u docker
-- No entries --
More debug information:
$ sudo systemctl status network.target
● network.target - Network
Loaded: loaded (/usr/lib/systemd/system/network.target; static; vendor preset: disabled)
Active: active since Mon 2017-01-23 02:54:39 PST; 2 months 29 days ago
Docs: man:systemd.special(7)
http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
Jan 23 02:54:39 mymachine systemd[1]: Starting Network.
Jan 23 02:54:39 mymachine systemd[1]: Reached target Network.
$ sudo systemctl status docker-storage-setup.service
● docker-storage-setup.service - Docker Storage Setup
Loaded: loaded (/usr/lib/systemd/system/docker-storage-setup.service; disabled; vendor preset: disabled)
Active: inactive (dead)
$ sudo systemctl status rhel-push-plugin.socket
Unit rhel-push-plugin.socket could not be found.
$ sudo systemctl status docker-cleanup.timer
● docker-cleanup.timer - Run docker-cleanup every hour
Loaded: loaded (/usr/lib/systemd/system/docker-cleanup.timer; disabled; vendor preset: disabled)
Active: inactive (dead)
In case someone has installed docker using snap, they can start the service using
sudo snap status docker #check the status
sudo snap start docker # start the service
Run this command to list all the services:
sudo systemctl list-units --type=service
Look for the correct Docker service name (in my case it is snap.docker.dockerd.service) then run:
sudo systemctl restart snap.docker.dockerd.service
It looks like you're missing the rhel-push-plugin.socket unit which is presumably part of a rhel-push-plugin package. You can try fixing that install, or you can install the upstream Docker package directly from Docker with the following as root:
curl -sSL https://get.docker.com/ | sh
Or more appropriately following the CentOS install guide from Docker. (The CentOS install tends to work on even a RHEL system when you have a supported version, which until the recent 20.10 release did not include CentOS 8 or RHEL 8.)
The upstream Docker install will be a more recent version of Docker, but it will not have the various RHEL modifications like the rhel-push-plugin.
Use the following command if your OS is Ubuntu, it will install Docker successfully:
apt install docker.io
if you have installed docker with snap you can check the status of the daemon like this:
sudo snap services docker
If the current column shows inactive then it's not running. Try starting it with this:
sudo snap start docker
Check the service again, if it's still not running after that you can check the logs:
sudo snap logs docker
which might give more hints on what's stopping it from running
For me, I had an error saying that docker could not create a symlink in /etc/docker/ because another file was in the way. Emptying the directory was not enough due to a known bug in the docker snap. The work-around was to delete the directory then refresh the snap (see https://forum.snapcraft.io/t/layouts-still-brittle-when-refreshing-snaps/26252/2)
sudo rm -rf /etc/docker
sudo snap refresh
I worked around the issue by simply doing the following:
$ sudo apt-get purge containerd.io docker-ce
$ rm -rf /var/lib/containerd
[reboot]
$ sudo apt-get install containerd.io docker-ce
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
Note
In some cases, you may need to reboot your instance to provide permissions for the ec2-user to access the Docker daemon. Try rebooting your instance if you see the following error:
Try installing Docker as root (sudo):
sudo yum install docker
See Installation on Red Hat Enterprise Linux.
I follow the instruction from this site: https://github.com/NVIDIA/nvidia-docker. to install nvidia-docker on the ubuntu 16.04 server. After running the command:
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
there is error:
$ sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
(Reading database ... 479592 files and directories currently installed.)
Preparing to unpack .../nvidia-docker_1.0.1-1_amd64.deb ...
Unpacking nvidia-docker (1.0.1-1) over (1.0.1-1) ...
dpkg: dependency problems prevent configuration of nvidia-docker:
nvidia-docker depends on docker-engine (>= 1.9.0) | docker-ce | docker-ee; however:
Package docker-engine is not installed.
Package docker-ce is not installed.
Package docker-ee is not installed.
dpkg: error processing package nvidia-docker (--install):
dependency problems - leaving unconfigured
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
nvidia-docker
$ sudo service docker status
^[[0;1;31m●^[[0m docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: ^[[0;1;31mfailed^[[0m (Result: exit-code) since Tue 2017-04-18 10:05:27 JST; 35s ago
Docs: https://docs.docker.com
Process: 18109 ExecStart=/usr/bin/dockerd -H fd:// ^[[0;1;31m(code=exited, status=1/FAILURE)^[[0m
Main PID: 18109 (code=exited, status=1/FAILURE)
Apr 18 10:05:27 NVIDIA2.cs179idcfcloud.internal systemd[1]: Starting Docker Application Container Engine...
Apr 18 10:05:27 NVIDIA2.cs179idcfcloud.internal dockerd[18109]: Error starting daemon: pid file found, ensure docker is not running or delete
/var/run/docker.pid
Apr 18 10:05:27 NVIDIA2.cs179idcfcloud.internal systemd[1]: ^[[0;1;39mdocker.service: Main process exited, code=exited, status=1/FAILURE^[[0m
Apr 18 10:05:27 NVIDIA2.cs179idcfcloud.internal systemd[1]: ^[[0;1;31mFailed to start Docker Application Container Engine.^[[0m
Apr 18 10:05:27 NVIDIA2.cs179idcfcloud.internal systemd[1]: ^[[0;1;39mdocker.service: Unit entered failed state.^[[0m
Apr 18 10:05:27 NVIDIA2.cs179idcfcloud.internal systemd[1]: ^[[0;1;39mdocker.service: Failed with result 'exit-code'.^[[0m
~$ sudo service docker start
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
how to solve it?
I have solved it. Firstly restart the ubuntu server with linux command(sudo shutdown -r now), and run the command : apt-get -f install(this command is suggested by the error information), then I install the docker-engine by the following site(https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04). then install nvidia-docker, it works!