Always include arguments when running Docker-Compose run

Asked

Viewed 133 times

1

I have a question about passing arguments in the Docker-Compose run:

I’m wearing a Dockerfile which has the following entrypoint:

ENTRYPOINT [ "/bin/wp" ]
CMD [ "--allow-root", "--help" ]

I need the --allow-root is always included.

If I execute docker-compose run [service] the argument goes by default, but if I run docker-compose run [service] option (option option...) i need to include the argument manually.

Can it ALWAYS include the argument? I need to edit Dockerfile (I’m not the author) or can I do it via Docker-Compose? I tried the command following this answer, but I was unsuccessful.

1 answer

0

When some argument is passed to the Docker-Compose run [service] command the arguments subscribe to the settings described in Docker-Compose.yml as described in the documentation https://docs.docker.com/compose/reference/run/ . Dockerfile cannot be edited, but you can create a new Dockerfile that is derived and overwrite entrypoint. Ex:

FROM vendor/image: tag

ENTRYPOINT [ "/bin/wp", "-allow-root" ]

This way the --allow-root parameter will always be present in entrypoint and the parameters passed after run will be interpreted together with entrypoint.

It is important to analyze whether this parameter in entrypoint will not impact the use of the image.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.