-
Notifications
You must be signed in to change notification settings - Fork 392
Strange effects happened to "Cmd" in container and container image. #163
Comments
Seeing if I can reproduce this... |
This is a duplicate of #116 |
Ah. Hadn't gotten that far into looking at this. I see in the code where we add the CMD, USER and WORKDIR values to the image on post build. So in theory the image should have received the command specified in container.yml as the CMD value. I'm also noticing that @struongpax is running Docker 1.12.0. Wondering if this is a 1.12.0 specific thing. I have not upgraded and tested 1.12.0 at all. Will run under 1.11.2 vs 1.12.0 and see what I find. |
On 1.11.2 it seems to work OK. After
ContainerConfig.Cmd has the value of the command running when the image was built:
When I run the container, it tries to run /root/start.sh:
|
Same result on 1.12.0:
|
@struongpax ansible-container seems to be working as expected.
Hopefully my explanation makes sense. I think we can say that ansible-container is working as expected. If I missed something, or if you have further questions, please feel free to re-open this issue. |
Honestly I do not think that this is not a bug. Here are what I want to show that the bug is there..... struong@mintlinux#0 filebeat pwd rsync -av --exclude=*.swp ~/ansible/roles/filebeat/ ansible/roles/filebeat export DOCKER_HOST=tcp://172.17.0.1:7777 cid=$(docker ps -a|grep ansible_filebeat | grep Exited |awk '{print $1}') echo $cid if [ ! -z "$cid" ]; then ansible-container --debug build --from-scratch struong@mintlinux#0 filebeat ./run sent 2,181 bytes received 137 bytes 4,636.00 bytes/sec Project name is filebeat Rendered Jinja Template:
volumes:
working_dir: /ansible-container/ansible/ Attaching to ansible_ansible-container_1 Successfully build the container. Deleting ansible/roles/*Here is my container.yml version: "1" Add your containers here, specifying the base image you want to build fromFor example:web:image: ubuntu:trustyports:- "80:80"command: ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND']dev_overrides:environment:- "DEBUG=1"
registries: {} Add optional registries used for deployment. For example:google:url: https://gcr.ionamespace: my-cool-project-xxxxxxBut I inspected the container image and the Cmd is not correct. struong@mintlinux#0 filebeat docker inspect filebeat-filebeat I have not upgraded docker or any other piece of software since the last time I filed this bug. Please advise. Thank you. |
I'm running from the latest code found in the develop branch. container.yml:
main.yml
Inspect the image produced by
However, if I run with ansible-container installed from PyPi, I do get the error. Here's the image inspection results:
|
@struongpax I believe this commit fixed the issue you're experiencing. It is only available by running Ansible Container from source. @j00bar Not sure this rises to the level of a hotfix. But... we could do a hotfix and release 0.1.1, if you feel it's appropriate. |
ISSUE TYPE
container.yml
main.yml
OS / ENVIRONMENT
SUMMARY
Using the container image from "ansible-containter build" with this command: docker run -d labs-labs:latest, my /root/start.sh did not get to run. When I inspected the container, I found this:
"Cmd": [
"sh",
"-c",
"while true; do sleep 1; done"
],
And inspecting the container image, I found the same "Cmd".
And when I used "ansible-container run", I got this:
labs ansible-container run
Attaching to ansible_ansible-container_1
Cleaning up Ansible Container builder...
Attaching to ansible_labs_1
labs_1 | Already up-to-date.
labs_1 | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
labs_1 | nginx: configuration file /etc/nginx/nginx.conf test is successful
ansible_labs_1 exited with code 0
but then when I inspected the stopped container I found this:
],
"Cmd": [
"/root/start.sh"
],
I really do not understand why command was specified in container.yml and the container image did have this set correctly. What are the logics that when using "ansible-container run" then the container got the right "Cmd" set.
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: