简体   繁体   中英

Docker command runs successfully from Docker run, but not when using CMD in Dockerfile

I am wrapping the Bitnami/Keycloak-Gatekeeper Docker image in a Dockerfile, and trying to run:

FROM bitnami/keycloak-gatekeeper:latest
COPY config.yml /opt/bitnami/keycloak-gatekeeper/config.yml
CMD ["/keycloak-gatekeeper --config /opt/bitnami/keycloak-gatekeeper/config.yml"]

This gives an error:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"/keycloak-gatekeeper --config /opt/bitnami/keycloak-gatekeeper/config.yml\": stat /keycloak-gatekeeper --config /opt/bitnami/keycloak-gatekeeper/config.yml: no such file or directory": unknown.

However, when I run this using a docker run command, everything executes as expected.

docker run -v "config.yml:/opt/bitnami/keycloak-gatekeeper/config.yml" bitnami/keycloak-gatekeeper:latest /keycloak-gatekeeper --config /opt/bitnami/keycloak-gatekeeper/config.yml

Why does this work directly through docker run, and not within the Dockerfile?

How can I solve this issue so that I can run using the Dockerfile?

CMD ["keycloak-gatekeeper", "--config", "/opt/bitnami/keycloak-gatekeeper/config.yml"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM