Reputation: 419
Following is the roleA.yml
- name: Create container
docker_container:
name: my_container
image: my_image:v0.2
ports:
- "0.0.0.0:8765:8765/tcp"
- "0.0.0.0:80:80/tcp"
state: started
command: service apache2 restart
Below is the main.yml
- name: Launching container.
hosts: localhost
environment:
PYTHONPATH: "/usr/local/lib/python2.7/site-packages"
roles:
- roleA
Following is the command i use to launch the container.
ansible-playbook main.yml
But whenever I execute this command, the container gets launched and within no seconds it gets exited. I even tried the different solutions suggested in Fail to start container using docker_container module after docker for mac update. I'm not sure what I'm doing wrong.
Please help. Thanks in advance. Let me know if you need some more info.
Upvotes: 0
Views: 1223
Reputation: 2467
You have to start apache service in foreground.
$ apachectl -d . -f httpd.conf -e info -DFOREGROUND
-d . sets the ServerRoot to the current directory. All relative paths within the configuration file will resolve to this root.
-f httpd.conf sets the configuration file to use. Note that this is relative to the ServerRoot, not the current working directory. In this case, the ServerRoot is the current working directory, so httpd.conf needs to exist in the current working directory.
-e info sets the logging level for startup. This is different than the log level set in the configuration file.
-DFOREGROUND defines the special apache directive that will cause the parent process to run in the foreground and not detach from the shell.
Upvotes: 1