This is the generic process of creating Docker containers from existing Ansible Playbooks. This example creates a Wordpress application from a random wordpress ansible playbook found on Internet.
If you want to create Docker containers and use them in a similar way than the traditional virtual environments. In order to do that we are taking Ubuntu Base image that is friendly with Docker containers.
Everything related with the multi-process approach is under ansible-wordpress
directory. Look at the file Makefile
to see the actual commands.
make container
make run_container
Now you can access to the wordpress application at port http://localhost:1800 and ssh at port 2200
make ssh-key
make run_registry
make push_registry
make pull_registry
make run_container_registry
Create two containers, one with MySQL (called "db") and the other one with Apache2 (called "web"). Apache2 will connect to MySQL in the container db.
Once both containers are up and running, you can access to wordpress at http://localhost:1800
If you need to access to the bash into the containers, you can use nsenter
(look for an example at ansible-wordpress/Makefile
), as ssh daemon is not working in the microservices.
Directory ansible-wordpress-microservices/dbserver/
make dbserver_container
make run_dbserver_container_mysql
Directory ansible-wordpress-microservices/webserver
make webserver_container
make run_webserver_container_apache