Docker Basic Command

Build a image

docker build -t <image_name> .
  • Dockerfile in the directory

Run a container

docker run -d --name <container_name> -p 8080:8080 app_image

Inside Container

docker exec -it <container_name> bash

Run docker-compose.yml

docker-compose up -d --build
docker-compose -f docker-compose.yml up -d --build

docker-compose run build in the background with specific environment file and specific docker-compose file.

docker-compose --env-file .env.prod -f  docker-compose-prod.yml up -d --build

Check logs

docker logs <container_name>
docker logs <container_name> -f
docker-compose logs
docker-compose logs -f

A dangling image is an image that is not tagged and is not used by any container. To remove dangling images type:

docker image prune
docker container prune


Where are stored the environment variables?

/proc/1/environ

Leave a Reply

Your email address will not be published.

ANOTE.DEV