Docker CLI
container
-
docker psshows all running container-
docker ps -ashows all existing container
-
-
docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]-
--name <container-name>gives the created container a custom name -
--rmremoves the container after stoping -
usually not desired-ddetached mode - stops the container after main process exits -
-itfor interactive processes - keep STDIN open (i), allocate a pseudo-tty (t)
-
-
typical example for testing:
docker run -it --rm --name test php:7.4 bash -
use bash in running container:
docker exec -it containerName bash
network
- list networks
docker network ls - add a network connection
docker network connect [OPTIONS] NETWORK CONTAINER
best practice
- use user flag:
--user $(id -u):$(id -g)to avoid problems on creating and accessing files