docker commands, flags, syntax Flashcards
-d
detach
-p
port
docker exec -it image_id ps -aux
full process listing of anything inside container
full process listing of anything inside container
docker exec -it image_id ps -aux
run shell inside docker container and connect to shell
docker exec -it image_id sh
docker exec -it image_id sh
run shell inside docker container and connect to shell
restart container
docker restart image_id
get logging info for container
docker logs image_id
get timestamped logs of container
docker logs image_id -t
remove a stopped container
docker rm <CONTAINER ID/CONTAINER NAME>
get further information about an image or a container.
docker inspect <CONTAINER ID/NAME OR IMAGE ID/NAME>
Create a volume with the volume name (used to persist data in a container beyond its lifecycle)
docker volume create <VOLUMENAME></VOLUMENAME>
List all volumes
docker volume ls
Use a docker compose file (compose.yaml) to run multi-container applications.
docker compose up -d
Stop and remove all the containers contained in the docker compose file (compose.yaml).
docker compose down
remove an image
docker rmi <IMAGE ID/IMAGE NAME>
Sets the base image for a build
FROM
adds metadata to an image
LABEL
runs / executes commands in a new layer (for installations or configuration)
RUN
copies NEW files.folders from src (client machine) to destination (new image layer)
COPY
add from a remote URL & do extraction etc (adding application/web files)
ADD
sets the default executable of a container & arguments (i.e. web server)
CMD
(can be overridden via docker run parameters)
sets the default executable of a container & arguments (but can’t be overridden)
ENTRYPOINT
(for very specific, single-purpose container)
informs docker what port the container app is running (metadata only! - no network configuration, just informs)
EXPOSE
tag upon building
docker build -t image_name