Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting Docker as Daemon on Ubuntu

Tags:

docker

ubuntu

Have been using Docker successfully for a few weeks but today when I was following a set of instructions which suggested adding the following two lines to the docker configuration file at /etc/init/docker.conf:

limit memlock unlimited unlimited limit nofile 262144 

It then suggested restarting Docker with sudo /etc/init.d/docker restart. When I did this under Ubuntu 14.04 it reported back that:

  • Docker is managed via upstart, try using service docker restart

I tried sudo service docker restart to which it reported:

stop: Unknown job: docker

start: Unknown job: docker

Now I'm stuck with the docker daemon not running! I tried rebooting but it's still not running and when run something as simple as sudo docker version I get:

Client version: 1.2.0 Client API version: 1.14 Go version (client): go1.3.1 Git commit (client): fa7b24f OS/Arch (client): linux/amd64 2014/10/01 09:57:45 Get http:///var/run/docker.sock/v1.14/version: dial unix /var/run/docker.sock: no such file or directory 

To troubleshoot I tried starting the docker daemon on the commandline with:

sudo docker -d 

And in another terminal window I am now able to run Docker normally. That's great but HOW do I get it to startup normally again? Also I notice that I have TWO docker config files:

/etc/init/docker.conf /etc/init/docker.io.conf 

They look like DUPs. Are they redundant? Which one should I be looking at? Do I need both?

I also noticed that this duplicity shows up when I run sudo service --status-all |grep docker I get both docker and docker.io as listed services. Grown.

like image 438
ken Avatar asked Oct 01 '14 09:10

ken


People also ask

How do I run a Docker as a daemon?

On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced. You can also start the Docker daemon manually and configure it using flags. This can be useful for troubleshooting problems. Many specific configuration options are discussed throughout the Docker documentation.

How do I start and stop Docker service in Ubuntu?

You should start docker using systemd/systemctl as that is the standard or correct way to start up docker. The first command basically tell docker to startup every time you boot into the host. To stop the docker process that is already running you can just press ctrl + c or send a kill signal to it.


2 Answers

There are multiple popular repositories offering docker packages for Ubuntu. The package docker.io is (most likely) from the Ubuntu repository. Another popular one is http://get.docker.io/ubuntu which offers a package lxc-docker (I am running the latter because it ships updates faster). Make sure only one package is installed. Not quite sure if removal of the packages cleans up properly. If sudo service docker restart still does not work, you may have to clean up manually in /etc/.

like image 164
Andreas Steffan Avatar answered Sep 21 '22 22:09

Andreas Steffan


I had the same issue on 14.04 with docker 1.9.1.

The upstart service command did work when I used sudo, even though I was root:

$ whoami root $ service docker status status: Unbekannter Auftrag: docker  $ sudo service docker status docker start/running, process 7394 

It seems to depend on the environment variables.

service docker status works when becoming root with su -, but not when only using su:

$ su Password: $ service docker status status: unknown job: docker $ exit $ su - Password: $ service docker status docker start/running, process 2342 
like image 26
cweiske Avatar answered Sep 21 '22 22:09

cweiske