coreos / bugs

Issue tracker for CoreOS Container Linux
https://coreos.com/os/eol/
147 stars 30 forks source link

Docker Service is not working with tcp socket #2027

Open pteichner opened 7 years ago

pteichner commented 7 years ago

Issue Report

Bug

When passing ignition config the service appear unavailable

Container Linux Version

NAME="Container Linux by CoreOS"
ID=coreos
VERSION=1409.5.0
VERSION_ID=1409.5.0
BUILD_ID=2017-06-22-2222
PRETTY_NAME="Container Linux by CoreOS 1409.5.0 (Ladybug)"
ANSI_COLOR="38;5;75"
HOME_URL="https://coreos.com/"
BUG_REPORT_URL="https://issues.coreos.com"
COREOS_BOARD="amd64-usr"
...
BUG_REPORT_URL="https://issues.coreos.com"

Environment

OpenStack private cloud

Expected Behavior

Docker socket should work locally and remotely

Actual Behavior

Unable to connect to Docker remote or local

core@host-192-168-1-203 ~ $ docker version
Client:
 Version:      1.12.6
 API version:  1.24
 Go version:   go1.7.5
 Git commit:   a82d35e
 Built:        Mon Jun 19 23:04:34 2017
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Reproduction Steps

  1. Create ignition config file and start OpenStack instance with it
  2. Try to connect to Docker

Other Information

core@host-192-168-1-203 ~ $ cat /media/configdrive/openstack/latest/user_data
{
  "ignition": {
    "version": "2.0.0",
    "config": {}
  },
  "storage": {
    "filesystems": [
      {
        "name": "ephemeral1",
        "mount": {
          "device": "/dev/vdb",
          "format": "ext4",
          "create": {
            "force": true
          }
        }
      }
    ]
  },
  "systemd": {
    "units": [
      {
        "name": "coreos-metadata.service",
        "dropins": [
          {
            "name": "20-clct-provider-override.conf",
            "contents": "[Service]\nEnvironment=COREOS_METADATA_OPT_PROVIDER=--provider=openstack-metadata"
          }
        ]
      },
      {
        "name": "var-lib-docker.mount",
        "enable": true,
        "contents": "[Unit]\nDescription=Mount ephemeral to /var/lib/docker\nRequires=format-ephemeral.service\nAfter=format-ephemeral.service\n[Mount]\nWhat=/dev/vdb\nWhere=/var/lib/docker\nType=ext4\n[Install]\nWantedBy=multi-user.target\n"
      },
      {
        "name": "docker.service",
        "dropins": [
          {
            "name": "10-wait-docker.conf",
            "contents": "[Unit]\nAfter=var-lib-docker.mount\nRequires=var-lib-docker.mount\n"
          }
        ]
      },
      {
        "name": "docker-tcp.socket",
        "enable": true,
        "contents": "[Unit]\nDescription=Docker Socket for the API\n\n[Socket]\nListenStream=2375\nBindIPv6Only=both\nService=docker.service\n\n[Install]\nWantedBy=sockets.target\n"
      },
      {
        "name": "coreos-metadata-sshkeys-workaround.service",
        "enable": true,
        "contents": "[Unit]\nDescription=CoreOS Metadata Agent Workaround (SSH Keys)\n\n[Service]\nType=oneshot\nExecStart=/usr/bin/coreos-metadata --provider=openstack-metadata --ssh-keys=core\n\n[Install]\nRequiredBy=multi-user.target\n"
      }
    ]
  },
  "networkd": {},
  "passwd": {}
pteichner commented 7 years ago

Followed instructions from here: https://coreos.com/os/docs/latest/customizing-docker.html And here: https://coreos.com/os/docs/latest/mounting-storage.html

lucab commented 7 years ago

@pteichner can you please check ignition logs? The configuration you pasted is invalid (missing closing }) but I'm not sure if that's just a copy-paste mistake.

Also, this works with socket activation, i.e. you should hit the port with -H tcp://<addr>:2375 to see docker engine running.

pteichner commented 7 years ago

@lucab sorry I've missed the copy of the closing brace.

Jun 23 09:20:46 localhost ignition[477]: files: op(6): [finished] processing unit "docker.service"
Jun 23 09:20:46 localhost ignition[477]: files: op(8): [started]  processing unit "docker-tcp.socket"
Jun 23 09:20:46 localhost ignition[477]: files: op(8): op(9): [started]  writing unit "docker-tcp.socket" at "etc/systemd/system/docker-tcp.socket"
Jun 23 09:20:46 localhost ignition[477]: files: op(8): op(9): [finished] writing unit "docker-tcp.socket" at "etc/systemd/system/docker-tcp.socket"
Jun 23 09:20:46 localhost ignition[477]: files: op(8): [finished] processing unit "docker-tcp.socket"
Jun 23 09:20:46 localhost ignition[477]: files: op(a): [started]  enabling unit "docker-tcp.socket"
Jun 23 09:20:46 localhost ignition[477]: files: op(a): [finished] enabling unit "docker-tcp.socket"

core@host-192-168-1-203 ~ $ docker -H tcp://127.0.0.1:2375 ps Cannot connect to the Docker daemon. Is the docker daemon running on this host?

core@host-192-168-1-203 ~ $ sudo netstat -antp | grep LIST
tcp6       0      0 :::22                   :::*                    LISTEN      1/systemd