寻找相关 container
# docker ps | grep thrift
15684b2ccdc0 docker.io/zhixingheyitian/sparkthrift@sha256:fb837a0635dbaa170cc09bd5ef451373e053e979270470712a12d774a75585ec "/opt/entrypoint.sh" 25 minutes ago Up 25 minutes k8s_sparkthrift-container_sparkthrift-pod_spark-project_05718697-a12d-11e9-8959-001e67b93b85_0
2b60355b8317 openshift/origin-pod:v3.11 "/usr/bin/pod" 35 minutes ago Up 35 minutes k8s_POD_sparkthrift-pod_spark-project_05718697-a12d-11e9-8959-001e67b93b85_0
登录
# docker exec -it k8s_sparkthrift-container_sparkthrift-pod_spark-project_05718697-a12d-11e9-8959-001e67b93b85_0 bash
bash-4.4$
docker exec -it b593b40f3376 bash
以root 用户登录
# docker exec -u root -it k8s_sparkthrift-container_sparkthrift-pod_spark-project_05718697-a12d-11e9-8959-001e67b93b85_0 bash
bash-4.4#
查看network
# docker network ls
NETWORK ID NAME DRIVER SCOPE
dd4a4d9d1033 bridge bridge local
0675271166bb host host local
eb874f87b2e5 none null local
Build
# cat Dockerfile
FROM quay.io/centos/centos:stream8
RUN dnf install net-tools iputils -y
RUN dnf install git -y
docker build --tag zhixingheyitian/centos8:kit-0.1 .
host network 模式
docker run -it --network=host --name centos8_container zhixingheyitian/centos8:kit-0.1 /bin/bash
docker build
# docker build --help
...
--network string Set the networking mode for the RUN instructions during build (default "default")
--target string Set the target build stage to build.
...
specify dockerfile
docker build --tag test/centos8:env-0.1 -f ./scripts/centos-8-stream.dockerfile .
docker ps
docker ps 默认显示的是 running containers
# docker ps --help
Usage: docker ps [OPTIONS]
List containers
Options:
-a, --all Show all containers (default shows just running)
删除 container
首先需要停止所有的容器
docker stop $(docker ps -a -q)
删除所有的容器
docker rm $(docker ps -a -q)
docker cp
docker cp /opt/dev 4faf71c7084e:/opt/