[英]Code works in Dockerfile but not in docker-compose.yml
I have to docker procedures: 1) First one uses a Dockerfile and does docker build -t d1.
我必须 docker 程序:1)第一个使用 Dockerfile 并执行docker build -t d1.
and then docker run -p 4022:22 d1
2) Second one uses a docker-compose.yml file, launched by command docker-compose up
然后docker run -p 4022:22 d1
2) 第二个使用 docker-compose.yml 文件,由命令docker-compose up
First one works, no error, second one fails, the command ansible-galaxy wich does https git operations never happens, but shows no error.第一个有效,没有错误,第二个失败,命令 ansible-galaxy 执行 https git 操作从未发生,但没有显示错误。 Any Idea?任何想法?
The Dockerfile content Dockerfile 内容
FROM myregistry.org/ansible-rhel:admin
COPY . /home/ansible/playbook-ldap-myapp
WORKDIR /home/ansible/playbook-ldap-myapp
USER ansible
RUN ansible-galaxy install -fr requirements.yml --roles-path roles/
The docker-compose.yml content docker-compose.yml 内容
version: '3'
networks:
public: {}
volumes:
playbook:
driver: local
driver_opts:
type: none
o: bind
device: $PWD
services:
ansible-admin:
image: myregistry.org/ansible-rhel:admin
ports:
- '4022:22'
networks:
- public
volumes:
- playbook:/home/ansible/playbook-ldap-myapp
working_dir: /home/ansible/playbook-ldap-myapp
user: ansible
command: ''
command: 'ansible-galaxy install -fr requirements.yml --roles-path roles/'
In your docker-compose.yml you have two command:
entries:在您的 docker-compose.yml 中,您有两个command:
条目:
command: ''
command: 'ansible-galaxy install -fr requirements.yml --roles-path roles/'
Per the Docker Compose file version 3 reference at: https://docs.docker.com/compose/compose-file/根据 Docker 撰写文件版本 3 参考: https://docs.docker.com/compose/compose-file/
The command:
attribute overrides the default executable that runs within your specified entrypoint, at run time. command:
属性在运行时覆盖在指定入口点内运行的默认可执行文件。
There can only be one command
, and the first command
you have specified ostensibly causes additional command
entries to be ignored.只能有一个command
,并且您指定的第一个command
表面上会导致其他command
条目被忽略。
Remove the command: ''
line and your Ansible command should run.删除command: ''
行,您的 Ansible 命令应该运行。 However it will be the only thing that runs.但是,它将是唯一运行的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.