{"action":"created","issue":{"url":"https://api.github.com/repos/lxc/lxd/issues/1770","repository_url":"https://api.github.com/repos/lxc/lxd","labels_url":"https://api.github.com/repos/lxc/lxd/issues/1770/labels{/name}","comments_url":"https://api.github.com/repos/lxc/lxd/issues/1770/comments","events_url":"https://api.github.com/repos/lxc/lxd/issues/1770/events","html_url":"https://github.com/lxc/lxd/issues/1770","id":141621929,"number":1770,"title":"How does one exactly run Docker in LXD?","user":{"login":"slava-vishnyakov","id":817931,"avatar_url":"https://avatars.githubusercontent.com/u/817931?v=3","gravatar_id":"","url":"https://api.github.com/users/slava-vishnyakov","html_url":"https://github.com/slava-vishnyakov","followers_url":"https://api.github.com/users/slava-vishnyakov/followers","following_url":"https://api.github.com/users/slava-vishnyakov/following{/other_user}","gists_url":"https://api.github.com/users/slava-vishnyakov/gists{/gist_id}","starred_url":"https://api.github.com/users/slava-vishnyakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slava-vishnyakov/subscriptions","organizations_url":"https://api.github.com/users/slava-vishnyakov/orgs","repos_url":"https://api.github.com/users/slava-vishnyakov/repos","events_url":"https://api.github.com/users/slava-vishnyakov/events{/privacy}","received_events_url":"https://api.github.com/users/slava-vishnyakov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-03-17T15:44:23Z","updated_at":"2016-03-31T18:56:59Z","closed_at":null,"body":"# Required information\r\n\r\n * Distribution: Ubuntu 15.10\r\n * Distribution version: 15.10\r\n * The output of \"lxc info\" or if that fails:\r\n```\r\napicompat: 0\r\nauth: trusted\r\nenvironment:\r\n  addresses: []\r\n  architectures:\r\n  - x86_64\r\n  - i686\r\n  certificate: |\r\n    -----BEGIN CERTIFICATE---\r\n    ....\r\n    -----END CERTIFICATE-----\r\n  driver: lxc\r\n  driverversion: 2.0.0.rc10\r\n  kernel: Linux\r\n  kernelarchitecture: x86_64\r\n  kernelversion: 4.2.0-27-generic\r\n  server: lxd\r\n  serverpid: 18226\r\n  serverversion: 2.0.0.rc3\r\n  storage: dir\r\n  storageversion: \"\"\r\nconfig: {}\r\npublic: false\r\n```\r\n\r\n# Issue description\r\n\r\nI'm trying to run Docker inside LXD but that fails at every step :) \r\n\r\nMaybe we could have a bit more detailed guide than what's available at https://github.com/lxc/lxd#how-can-i-run-docker-inside-a-lxd-container ?\r\n\r\n# Steps to reproduce\r\n\r\nInstall clean Ubuntu 15.10\r\n\r\nInstall Docker so that we can build Docker from source (`checkout v1.10.0.serge.2`).\r\n\r\nWe can't build custom binary inside container, since that requires working Docker, so let's build on host.\r\n\r\n```\r\n(on host)\r\napt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D\r\necho \"deb https://apt.dockerproject.org/repo ubuntu-wily main\" > /etc/apt/sources.list.d/docker.list; \\\r\napt-get update\r\napt-get install -y docker-engine\r\n```\r\n\r\nBuild custom Docker from `v1.10.0.serge.2`\r\n\r\n```\r\n(on host)\r\napt-get update && apt-get install -y build-essential\r\ngit clone https://github.com/hallyn/docker.git\r\ncd docker\r\ngit checkout v1.10.0.serge.2\r\nmake build\r\nmake binary\r\n```\r\n\r\nRun Docker host container\r\n\r\n```\r\n(on host)\r\nlxc launch ubuntu:15.10 my-docker-host -p default -p docker\r\nlxc exec my-docker-host bash\r\n```\r\n\r\n(now we are inside container, I guess only binary would be not enough and we need all service definition files, so let's install unmodified default Docker first)\r\n\r\n```\r\n(in container)\r\napt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D\r\necho \"deb https://apt.dockerproject.org/repo ubuntu-trusty main\" > /etc/apt/sources.list.d/docker.list\r\napt-get update\r\napt-get install -y docker-engine\r\n```\r\n\r\nNow the Docker fails, complaining \r\n\r\n```\r\nError starting daemon: AppArmor enabled on system but the docker-default profile could not be loaded\r\n```\r\n\r\nOk, let's remove apparmor\r\n\r\n```\r\n(in container)\r\napt-get purge apparmor\r\n```\r\n\r\nNow docker daemon starts, bring the custom docker binary from host system to inside container\r\n\r\n```\r\n(in container) \r\nrm /usr/bin/docker\r\n\r\n(on host) \r\nlxc file push bundles/1.10.0/binary/docker-1.10.0 my-docker-host/usr/bin/docker\r\n```\r\n\r\nOk, let's restart docker daemon and make sure we run the patched version\r\n\r\n```\r\n(in container)\r\n# sudo service docker restart\r\n# docker version\r\nClient:\r\n Version:      1.10.0\r\n API version:  1.22\r\n Go version:   go1.5.3\r\n Git commit:   ab8e54b\r\n Built:        Thu Mar 17 15:08:23 2016\r\n OS/Arch:      linux/amd64\r\n\r\nServer:\r\n Version:      1.10.0\r\n API version:  1.22\r\n Go version:   go1.5.3\r\n Git commit:   ab8e54b\r\n Built:        Thu Mar 17 15:08:23 2016\r\n OS/Arch:      linux/amd64\r\n```\r\n\r\nGood, ab8e54b is the commit from https://github.com/hallyn/docker/commits/v1.10.0.serge.2\r\n\r\nLet's try to run it..\r\n\r\n```\r\n(in container)\r\n# docker run hello-world\r\ndocker: Error response from daemon: error creating aufs mount to /var/lib/docker/aufs/mnt/bf39fe22b47ce5670e8ad399bdb4025972d24bf2587cdd470d67fea0ba84821f-init: operation not permitted.\r\n```\r\n\r\nWell, I'm stuck :) \r\n\r\nAm I doing it The Stupid Way™? Am I missing something? \r\nIs this not working because of 15.10? \r\nI can't seem to get 16.04 running in container - apt-get update fails badly https://pastebin.ubuntu.com/15407782/ \r\n\r\nLittle help? \r\n\r\nCan we update https://github.com/lxc/lxd#how-can-i-run-docker-inside-a-lxd-container with more instructions?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/lxc/lxd/issues/comments/204077752","html_url":"https://github.com/lxc/lxd/issues/1770#issuecomment-204077752","issue_url":"https://api.github.com/repos/lxc/lxd/issues/1770","id":204077752,"user":{"login":"hallyn","id":1359441,"avatar_url":"https://avatars.githubusercontent.com/u/1359441?v=3","gravatar_id":"","url":"https://api.github.com/users/hallyn","html_url":"https://github.com/hallyn","followers_url":"https://api.github.com/users/hallyn/followers","following_url":"https://api.github.com/users/hallyn/following{/other_user}","gists_url":"https://api.github.com/users/hallyn/gists{/gist_id}","starred_url":"https://api.github.com/users/hallyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hallyn/subscriptions","organizations_url":"https://api.github.com/users/hallyn/orgs","repos_url":"https://api.github.com/users/hallyn/repos","events_url":"https://api.github.com/users/hallyn/events{/privacy}","received_events_url":"https://api.github.com/users/hallyn/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T18:56:59Z","updated_at":"2016-03-31T18:56:59Z","body":"Thanks, so yeah the question is whether we want to put container detection into the init scripts, or handle it some other way."}}