Useful Docker Commands To Remember

# To run docker-compose to build an image container using yml file
docker-compose -f docker/docker-compose.yml build
# To create and start containers
docker-compose up
# To show all the docker images
docker image ls -a
# To show all stopped and running docker container
docker ps -a
# To run a command in a running container and start the session
docker exec -it docker_web_1 /bin/bash
# To stop all running containers
docker stop $(docker ps -a  -f status=running -q)
# To start all exited(stopped) containers
docker start $(docker ps -a  -f status=exited -q)
# To remove all the docker images
docker image rm $(docker image ls -a -q)
# To build the docker image from a Dockerfile with the ‘name:tag’ format
docker build -t [repository-name]:[Tag] --no-cache -f Dockerfile .
Example:
       docker build -t example/sample:1.0 --no-cache -f Dockerfile .
# Tag the image with another name
docker tag [repository-name1]:[Tag] [repository-name2]:[Tag]
Example:
       docker tag example/sample:1.0 example1/sample1:latest
# To Push a docker image to a repository
docker push example1/sample1:latest
#Docker CLI reference
https://docs.docker.com/reference/