Docker Frequently used commands

Enter the container

$ docker-compose exec #{container} bash 

Stop / Delete

#Stop all containers
docker stop $(docker ps -q)
#Delete all containers
docker rm $(docker ps -q -a)
#Delete all images
docker rmi $(docker images -q)


docker build [ -t {image name}[ :{Tag name}] ]{Directory with Dockerfile}


$ docker run [option]image[:tag|@Digest value] [command] [argument...]

#rm:Automatic image deletion when container is closed
#name:Give the container a name
$ docker run --rm --name test -it image:tag bash

Copy between host and container

docker cp (ID or container name):(Path in the container) (Host path)

(ex)docker cp aabade1747be:/usr/local/apache2/conf/httpd.conf ./


Enter mysql

mysql -h host -u root -pmypass

Open in a tab by terminal

command + t

Recommended Posts

Docker Frequently used commands
Summary of frequently used Docker commands
Introduction to Docker (1) Frequently used commands
Summary of frequently used commands in Rails and Docker
git flow Frequently used commands Memo
[Docker] Other frequently used (probably) Docker Instructions
Docker basic commands
Frequently used functions and commands of Xcode
Docker terms and commands
Frequently used docker-compose command
Frequently used Java generics
Docker Compose basics and commands
Frequently used processes in SpreadSheet
rails console Frequently used operations
Frequently used Maven command collection
A collection of commands that were frequently used on heroku
[Memo] Commands used when using Docker (stop container, delete, delete image)
Docker network related research & configuration commands
Frequently used methods in Active Record
Commands often used in MySQL operations
Docker related commands (notes for yourself)
Edit Mysql with commands in Docker environment
What is Docker? What purpose is it used for?
Introduction of Docker Hub and commands Self-learning ①
Commands that helped resolve errors in Docker