Junior — Middle
What parameters and options are available when launching a Docker container to configure its behavior?
sobes.tech AI
Answer from AI
When launching a Docker container using the docker run command, there are many parameters available to configure its behavior. Here are the main ones:
-dor--detach— run the container in the background.-por--publish— port forwarding from the host to the container, e.g.,-p 8080:80.-vor--volume— mounting volumes or directories, e.g.,-v /host/path:/container/path.--name— assign a name to the container.--envor-e— pass environment variables, e.g.,-e ENV=prod.--rm— automatically remove the container after stopping.--network— connect the container to a specific network.--restart— container restart policy (e.g.,always,on-failure).--memoryand--cpus— resource limits for memory and CPU.
Example of launching a container with port forwarding, environment variable, and name:
docker run -d -p 8080:80 -e ENV=production --name my_container nginx