Bug 1071605

Summary: sshd not working in fedora image
Product: [Fedora] Fedora Reporter: Paolo Antinori <pantinor>
Component: docker-ioAssignee: Lokesh Mandvekar <lsm5>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: admiller, dcaroest, golang-updates, jkeck, lsm5, mattdm, mgoldman, skottler, vbatts
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-05-15 10:51:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Paolo Antinori 2014-03-02 09:16:49 UTC
Description of problem: 

Running sshd on a fresh docker fedora image fails with this error:
Failed to get D-Bus connection: No connection to service manager.


Version-Release number of selected component (if applicable):

$ docker -v
Docker version 0.8.0, build cc3a8c8/0.8.0

$ docker inspect fedora
[{
    "id": "58394af373423902a1b97f209a31e3777932d9321ef10e64feaaa7b4df609cf9",
    "parent": "8abc22fbb04266308ff408ca61cb8f6f4244a59308f7efc64e54b08b496c58db",
    "created": "2014-02-03T16:10:40.500814677Z",
    "container": "f718f19a28a5147da49313c54620306243734bafa63c76942ef6f8c4b4113bc5",
    "container_config": {
        "Hostname": "88807319f25e",
        "Domainname": "",
        "User": "",
        "Memory": 0,
        "MemorySwap": 0,
        "CpuShares": 0,
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": null,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "HOME=/",
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Cmd": [
            "/bin/sh",
            "-c",
            "#(nop) ADD fedora-20-medium.tar.xz in /"
        ],
        "Dns": null,
        "Image": "8abc22fbb04266308ff408ca61cb8f6f4244a59308f7efc64e54b08b496c58db",
        "Volumes": null,
        "VolumesFrom": "",
        "WorkingDir": "",
        "Entrypoint": null,
        "NetworkDisabled": false,
        "OnBuild": null
    },
    "docker_version": "0.6.3",
    "author": "Lokesh Mandvekar \u003clsm5\u003e - ./buildcontainers.sh",
    "config": {
        "Hostname": "88807319f25e",
        "Domainname": "",
        "User": "",
        "Memory": 0,
        "MemorySwap": 0,
        "CpuShares": 0,
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": null,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "HOME=/",
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Cmd": null,
        "Dns": null,
        "Image": "8abc22fbb04266308ff408ca61cb8f6f4244a59308f7efc64e54b08b496c58db",
        "Volumes": null,
        "VolumesFrom": "",
        "WorkingDir": "",
        "Entrypoint": null,
        "NetworkDisabled": false,
        "OnBuild": null
    },
    "architecture": "x86_64",
    "Size": 385520098
}]


How reproducible:
Always


Steps to Reproduce:
1. docker run -t -i fedora bash
2. bash-4.2# yum install -y openssh-server
3. bash-4.2# systemctl start sshd

Actual results:
Failed to get D-Bus connection: No connection to service manager.

bash-4.2# service sshd status
Redirecting to /bin/systemctl status  sshd.service
Failed to get D-Bus connection: No connection to service manager.


Expected results:
A running sshd daemon

Additional info:

Comment 1 Matthew Miller 2014-04-03 11:45:03 UTC
It's not sshd that's not working -- it's that you're not running systemd. The process you're running in your container is "bash". That means any services normally started by systemd aren't there -- not to mention systemd itself.

You *can* run "docker run systemd", but results are unpredictable at best right now. Work on polishing that is a perfectly interesting project for someone, but as far as I know no one is focusing on it.

You could also run the container with sshd directly -- that should work.

Comment 2 Paolo Antinori 2014-04-03 12:55:43 UTC
Thanks Matt for the explanation. At that time I had bypassed the problem using Centos images that allow me to use 

service sshd start

that keeps it simpler by my point of view.

Comment 3 Matthew Miller 2014-04-03 13:18:09 UTC
(In reply to Paolo Antinori from comment #2)
> Thanks Matt for the explanation. At that time I had bypassed the problem
> using Centos images that allow me to use 
> 
> service sshd start
> 
> that keeps it simpler by my point of view.

So, that just runs '/etc/init.d/sshd start', which in turn runs /usr/sbin/sshd. There's nothing fundamentally different from just doing that directly (although the script does set up host keys if they don't exist).