docker command help
1 | docker command --help |
use images
list images
1 | docker images |
start container by image
1 | docker run -t -i ubuntu:16.04 /bin/bash |
search images
1 | docker search mysql |
get new images
1 | docker pull ubuntu:18.04 |
delete image
1 | docker rmi ubuntu:18.04 |
[more operations][https://www.runoob.com/docker/docker-image-usage.html]
use container
start container
1 | docker run -t -i ubuntu:16.04 /bin/bash ## -d background |
show containers
1 | docker ps -a |
stop & start & restart container
1 | docker start container_id ## RUN IN THE BACKGROUND |
enter container
1 | docker attach container_id ## use exit will stop container |
1 | docker exec -it container_id /bin/bash ## use exit will not stop container |
export container
1 | docker export container_id > container.tar |
import container_snap to image
1 | cat docker/mysql.tar | docker import - mysql:v1 |
delete container
1 | docker rm -f container_id |
show container’s port mapping
1 | docker port container_id |
connect container by port mapping
1 | docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD = 123456 mysql |
connect containers
create a docker network
1 | docker network create -d bridge hadoop-net |
show networks
1 | docker network ls |
run a container and connect to the network
1 | docker run -itd --name hadoop1 --network hadoop-net ubuntu /bin/bash |