Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set "ENV container docker" for CentOS and friends #192

Merged
merged 1 commit into from Mar 2, 2016

Conversation

mmckinst
Copy link
Contributor

I was having similar problems to issue #109 where I'm using kitchen-docker to do acceptance testing for puppet modules on centos 7 with systemd. EG after running a puppet module, run serverspec or bats to ensure the module actually installed, configured, and started the service correctly.

With this patch and the below config, you can get systemd running on the centos7 docker container.

driver:
  name: docker
  privileged: true
  provision_command: 
    - /usr/bin/systemctl enable sshd
  run_command: /usr/sbin/init

https://developerblog.redhat.com/2014/05/05/running-systemd-within-docker-container/ and https://hub.docker.com/_/centos/ have a bunch of other things you might have to do regarding /sys/fs/cgroup and deleting some systemd "wants" files but I've found I don't have to do that. Someone else's mileage may vary.

@acondrat
Copy link

@mmckinst Thanks for the fix. I had a similar problem. My centos7 docker container was running fine on an Ubuntu host but not on a Centos host. The container is being started but it's missing sshd.

Would love to see it merged into master and released!

coderanger added a commit that referenced this pull request Mar 2, 2016
set "ENV container docker" for CentOS and friends
@coderanger coderanger merged commit 21736ea into test-kitchen:master Mar 2, 2016
@trinitronx
Copy link

@mmckinst: This is excellent! Just having it in the main centos platform commands is great & the single environment variable shouldn't interfere with anything unless systemd is activated with the .kitchen.yml settings you mention! I've run into this magic incantation to get systemd working in Docker before, but surprisingly it wasn't well documented then. Yet, indeed as you've found, it's now documented by RedHat and the official CentOS Docker Hub image, which is also great!

Trying to band-aid patch this myself manually just to set an ENV variable felt wrong & easy to forget, and seeing that all the other pull requests for setting environment variables failed (#165, #123). Great to see this merged in!

@cruwe
Copy link
Contributor

cruwe commented Jun 24, 2016

With recent debian:stretch containers, it is necessary to set container=docker as well. It might be an idea to reopen #192 and extend the fix similarly to debian and ubuntu. I have tested with ubuntu and it does not seem to hurt.

cruwe added a commit to cruwe/kitchen-docker that referenced this pull request Jun 24, 2016
When running /sbin/init from systemd in debian:stretch (recent, unable
to determine since when), it is necessary to include the enviroment
variable container=docker in the Dockerfiles. This is essentially the
same as for recent CentOSes as previously fixed in test-kitchen#192.

Tests with ubuntu-14.04 have shown no hurts and I strongly suspect the
same for other debian-based images.

	modified:   lib/kitchen/driver/docker.rb
coderanger added a commit that referenced this pull request Jul 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants