2

I'm new to docker and trying to implement docker using chef on centos 7.1 Below is the basic code I wrote for installing, pulling centos image and creating container.

All the 3 tasks are executing successfully. Since the containers are in stop mode I tried to start manually by typing docker start containerid. When I checked docker ps I found the container is not started . I tried for several times but couldn't start the container.

Docker code using chef

docker_service 'default' do
  action [:create, :start]
end

docker_image 'centos' do
  action :pull
end

docker_container 'check2' do
  repo 'centos'
  action :create
end

Docker info:

Containers: 6
 Running: 1
 Paused: 0
 Stopped: 5
Images: 3
Server Version: 1.12.1
Storage Driver: devicemapper
 Pool Name: docker-8:1-523814-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 441.3 MB
 Data Space Total: 107.4 GB
 Data Space Available: 28.08 GB
 Metadata Space Used: 1.159 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.146 GB
 Thin Pool Minimum Free Space: 10.74 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.107-RHEL7 (2016-06-09)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 3.10.0-229.4.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 6.807 GiB
ID: R24R:ORHY:XJQW:2HNI:U5TV:UGF7:B7VX:P6Z6:UHSR:YIMR:VGJT:4URU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
 127.0.0.0/8

Would you please help me

1

1 Answer 1

2

By default, the centos image will run /bin/bash which will exit immediately without a tty (-t) and standard input (-i) available.

Try running something in the container

docker_container 'check2' do
  repo 'centos'
  command 'top -b -d 5'
end
3
  • Thanks, its working. As a beginner i have following doubts ,request you to suggest me on these 1)what is the best practice to implement docker in chef (either i can use docker-file or recipes in chef for defining tasks) 2) Is bootstrapping is required for each container for doing tasks inside it? 3) Can i get good material or a link for brief reading of docker using chef . Thank very much in advance
    – kumar
    Commented Sep 27, 2016 at 8:36
  • @kumar That seems like a good "chef and docker" question to add to the site.
    – Matt
    Commented Sep 29, 2016 at 21:58
  • My confusion is about what to do next in order to bootstrap a container. Right now I wrote a couple of recipe that will install the docker and create a container on chef node. My aim is to do container bootstraping so that i can install jenkins inside it. I gone through many sites but did not get clarity. Please advice
    – kumar
    Commented Sep 30, 2016 at 3:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.