Ynnckth
Ynnckth

Reputation: 95

Cloud-init to configure an Ubuntu docker container?

Is it possible to use a cloud-init configuration file to define commands to be executed when a docker container is started?

I'd like to test the provisioning of an Ubuntu virtual machine using a docker container. My idea is to provide the same cloud-init config file to an Ubuntu docker container.

Upvotes: 2

Views: 2502

Answers (1)

David Maze
David Maze

Reputation: 158647

No. If you want to test a VM setup, you need to use actual virtualization technology. The VM and Docker runtime environments are extremely different and you can't just substitute one technology for the other. A normal Linux VM startup will run a raft of daemons and startup scripts – systemd, crond, sshd, ifconfig, cloud-init, ... – but a Docker container will start none of these and will only run the single process in the container.

If your cloud-init script is ultimately running a docker run command, you can provide an alternate command to that container the same way you could docker run on your development system. But a Docker container won't look to places like the EC2 metadata service to find its own configuration usually, and it'd be unusual for a container to run cloud-init at all.

Upvotes: 5

Related Questions