Bug 1071605 - sshd not working in fedora image
Summary: sshd not working in fedora image
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: docker-io
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lokesh Mandvekar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-02 09:16 UTC by Paolo Antinori
Modified: 2014-07-01 23:00 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-05-15 10:51:07 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

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).


Note You need to log in before you can comment on or make changes to this bug.