Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 538848

Summary: app-emulation/docker uses /var/run and silently fails to start if it doesn't exist
Product: Gentoo Linux Reporter: Dries Kimpe <dries>
Component: Current packagesAssignee: William Hubbs <williamh>
Status: RESOLVED OBSOLETE    
Severity: normal CC: dries, jstein, mrueg, orzel, xarthisius, zlogene
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 332633    
Attachments: docker-1.4.1-r1.ebuild
Patch for upstream
patch between 1.4.1 and 1.4.1-r1

Description Dries Kimpe 2015-02-04 21:20:54 UTC
docker-1.4.1 (and possibly older versions) depends on /var/run existing.
/etc/init.d/docker fails silently if /var/run does not exist.

Solution:
1- Add DOCKER_HOST config option in conf.d/docker
2- Default it to file in /run
3- add env.d to set DOCKER_HOST to the same.

Without 1 and 3, docker will not work out of the box (fails to start or client fails to connect).


Reproducible: Always

Steps to Reproduce:
1. remove /var/run (happens automatically on some systems)
2. /etc/init.d/docker start
3. Will indicate success, but daemon will not run.
Comment 1 Dries Kimpe 2015-02-04 21:41:51 UTC
Created attachment 395554 [details]
docker-1.4.1-r1.ebuild
Comment 2 Dries Kimpe 2015-02-04 21:42:20 UTC
Created attachment 395556 [details, diff]
Patch for upstream
Comment 3 Dries Kimpe 2015-02-04 21:51:22 UTC
Upstream pull request submitted.
Comment 4 Dries Kimpe 2015-02-04 21:55:22 UTC
Created attachment 395558 [details, diff]
patch between 1.4.1 and 1.4.1-r1
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2015-02-05 01:18:38 UTC
Comment on attachment 395554 [details]
docker-1.4.1-r1.ebuild

--- docker-1.4.1.ebuild
+++ docker-1.4.1-r1.ebuild
@@ -20,7 +20,7 @@
        [ "$DOCKER_GITCOMMIT" ] || die "DOCKER_GITCOMMIT must be added manually for each bump!"
 fi

-inherit bash-completion-r1 linux-info multilib systemd udev user
+inherit bash-completion-r1 linux-info multilib systemd udev user eutils

 LICENSE="Apache-2.0"
 SLOT="0"
@@ -134,6 +134,8 @@
 }

 src_prepare() {
+    # Don't use /var/run
+    epatch "${FILESDIR}/${P}-var-run.patch"
        # allow user patches (use sparingly - upstream won't support them)
        epatch_user
 }
@@ -212,6 +214,9 @@
                mkdir -p "${D}/usr/share/${PN}/contrib"
                cp -R contrib/* "${D}/usr/share/${PN}/contrib"
        fi
+
+    echo -n "DOCKER_HOST=\"unix:///run/docker.unix\"" > "${T}/90docker"
+       doenvd "${T}/90docker"
 }

 pkg_postinst() {
Comment 6 SpanKY gentoo-dev 2015-07-28 01:30:10 UTC
i don't know if we've moved to supporting systems w/out /var/run entirely.  there's really no reason for it to not be a symlink to /run.
Comment 7 Jeff Kowalczyk 2015-09-29 16:49:13 UTC
Can we have a pronouncement on the correct way for the end user to fix their system, and shortly thereafter an updated ebuild in portage?

The problem still manifests with current app-emulation/docker-1.8.2. I'd like to get Docker running on Gentoo ASAP.

Thanks.
Comment 8 Jeff Kowalczyk 2015-09-29 19:02:18 UTC
As follow-up I have attempted to the following, but docker-1.8.2 still doesn't run:

% grep HOST /etc/conf.d/docker /etc/env.d/90docker                                                                                    
/etc/conf.d/docker:DOCKER_HOST="unix:///run/docker.sock"
/etc/env.d/90docker:DOCKER_HOST="unix:///run/docker.sock

% grep docker /etc/group
docker:x:993:myuser

The socket files are created, persist after service stop, and are hardlinks of
each other, all of which I presume is as intended:

% /etc/init.d/docker zap
 * Manually resetting docker to stopped state
% ls -al /var/run/docker.sock /run/docker.sock 
srw-rw---- 1 root docker 0 Sep 29 10:03 /run/docker.sock
srw-rw---- 1 root docker 0 Sep 29 10:03 /var/run/docker.sock

% sudo /etc/init.d/docker start
 * Starting docker daemon ...    [ ok ]

% sudo /etc/init.d/docker status                                                                                                      
 * status: crashed

% docker images
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
Comment 9 Kacper Kowalik (Xarthisius) (RETIRED) gentoo-dev 2015-09-30 15:05:16 UTC
Are you sure it's the same problem? Sounds like you applied the workaround and it still crashes. Could you try using "vanilla" gentoo docker with /var/run -> /run symlink? Does system log show why docker is dying? You can always start daemon manually and see what's going on.
Comment 10 Jeff Kowalczyk 2015-10-01 04:52:57 UTC
Thank you for the suggestion, you are correct:

- applying the suggested fix in the original bug report at top works:

- docker daemon wasn't starting on my system due to confusion about the storage driver. I had used aufs in the past, and use devicemapper today.

% docker -d
Warning: '-d' is deprecated, it will be removed soon. See usage.
WARN[0000] please use 'docker daemon' instead.          
FATA[0000] Error starting daemon: open /var/run/docker.pid: permission denied 

% sudo docker daemon
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) 
FATA[0000] Error starting daemon: error initializing graphdriver: "/var/lib/docker" contains other graphdrivers: devicemapper; Please cleanup or explicitly choose storage driver (-s <DRIVER>) 

% sudo docker daemon -s devicemapper
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) 
INFO[0000] Option DefaultDriver: bridge                 
INFO[0000] Option DefaultNetwork: bridge                
INFO[0000] Firewalld running: false                     
INFO[0000] Loading containers: start.                   
..........................
INFO[0000] Loading containers: done.                    
INFO[0000] Daemon has completed initialization          
INFO[0000] Docker daemon                                 commit=0a8c2e3 execdriver=native-0.2 graphdriver=devicemapper version=1.8.2
^CINFO[0013] Processing signal 'interrupt'                

The docker init script should use 'docker daemon' instead of 'docker -d' which is to be deprecated.
Comment 11 Mikle Kolyada archtester Gentoo Infrastructure gentoo-dev Security 2020-01-17 08:07:00 UTC
Should not be a problem for really long time.