Run a command in a new Docker container.
# To run command in a new container from a tagged image:
docker run <image:tag> <command>
# To run command in a new container in background and display its ID:
docker run -d <image> <command>
# To run command in a one-off container in interactive mode and pseudo-TTY:
docker run --rm -it <image> <command>
# To run command in a new container with passed environment variables:
docker run -e '<variable>=<value>' -e <variable> <image> <command>
# To run command in a new container with bind mounted volumes:
docker run -v </path/to/host_path>:</path/to/container_path> <image> <command>
# To run command in a new container with published ports:
docker run -p <host_port>:<container_port> <image> <command>
# To run command in a new container overwriting the entrypoint of the image:
docker run --entrypoint <command> <image>
# To run command in a new container connecting it to a network:
docker run --network <network> <image>
# ---
# To override the default command to execute (ENTRYPOINT) in an image at runtime:
docker run --rm -it --entrypoint="" <image> /bin/sh
# To run a command and assign a container name:
docker run --name <container_name> <image:tag> <command>