Common commands

# View the Docker image
docker images
# Check the Docker container
docker ps -a
# View the running container
docker ps
# View mirror information
docker inspect {ID}
# delete container
docker rm {ID}
# delete mirror
docker rmi {ID}
# enter mirror
docker exec -it {ID} bash
Copy the code

Run the mirror

Run the mysql image
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
Copy the code

Mount the container

docker run -d -p 8080:8080 v /usr/local/maven/maven3:/usr/local/ maven maven3 container id

docker run-it -v ~/software:/ MNT /software java-base:1.8 /bin/bash
Copy the code
  • -v mounts the directory of the host to the container
  • The colon precedes the host directory and the colon precedes the container application directory

Build the mirror

docker build -t java_maven
Copy the code