# Add alias to user profile
RUN echo "alias ll='ls -la'" >> /root/.bashrc
Execute the Docker Compose run
command, from the same directory that contains your docker-compose.yml file.
# Simple form
docker compose run -it SERVICE-NAME-IN-COMPOSE-YML "COMMAND" "ARGS-TO-COMMAND"
# Simple form, to get a shell
docker compose run -it SERVICE-NAME-IN-COMPOSE-YML "/bin/bash"
# If you need to override the entrypoint
docker compose run -it --entrypoint /bin/bash SERVICE-NAME-IN-COMPOSE-YML "COMMAND" "ARGS-TO-COMMAND"
run
will ALWAYS start a new instance of a container!
In contrast, exec
will operate on a running container (and won't create a new instance)!
Note: On some platforms, use
docker-compose
instead ofdocker compose
.
The Docker for Mac app comes packed with QEMU, a popular OSS emulator. Therefore, Docker can run both arm64 and amd64 images on Macs with Apple Silicon.
Read more here: (scroll to “Using Docker”) https://earthly.dev/blog/using-apple-silicon-m1-as-a-cloud-engineer-two-months-in/
If you have an Apple Silicon Mac and you need to run a Docker image that does not have an ARM build, then you can force Docker to download an amd64 image and emulate.
Some ways to do this: (there’s probably others, like docker pull etc.)
- If you’re using Docker Compose with no Dockerfile to build from, for the particular service, just include platform: linux/amd64.
- If you’re using a Dockerfile, use the --platform switch in the FROM. For example FROM --platform=linux/amd64 centos .
References:
This content is shared under a Creative Commons Attribution-ShareAlike 4.0 International.