docker run --rm mcr.microsoft.com/dotnet/core/samples
docker info
docker images
install base container images:
docker pull microsoft/dotnet-samples:aspnetapp
docker pull mcr.microsoft.com/dotnet/core/sdk:2.2-alpine
docker pull mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine
docker pull nginx
docker pull mysql
docker pull alpine
docker engine:
{
“registry-mirrors”: [
“https://khec465u.mirror.aliyuncs.com”
],
“insecure-registries”: [],
“debug”: true,
“experimental”: false
}
Docker Engine default:
{
“builder”: {
“gc”: {
“defaultKeepStorage”: “20GB”,
“enabled”: true
}
},
“experimental”: false,
“features”: {
“buildkit”: true
}
}
docker run -it --rm -p 8000:80 --name aspnetcore_sample microsoft/dotnet-samples:aspnetapp
docker inspect -f “{{ .NetworkSettings.IPAddress }}” aspnetcore_sample
route add 172.17.0.0 mask 255.255.240.0 172.31.176.1 -p
docker run --rm hello-world
docker image tag hello-world harbor-k8s.wzs.wistron.com.cn/season/test/hello-world
docker images
docker login harbor-k8s.wistron.com
docker push harbor-k8s.wzs.wistron.com.cn/season/test/hello-world
route add 172.17.0.0 mask 255.255.240.0 172.31.176.1 -p
docker login harbor-k8s.wzs.wistron.com.cn
docker run -d -p 3307:3306 --name my-mysql -e MYSQL_ROOT_PASSWORD=Password@123 -v d:/app-data:/var/lib/mysql mysql
docker rm hitcount2 hitcount1 -f
172.17.0.2
172.19.0.2
docker stop nginx-server1
docker network disconnect bridge nginx-server1
docker network connect my-bridge-network nginx-server1
docker start nginx-server1
docker inspect nginx-server1
docker stop nginx-server1 nginx-server2
docker rm nginx-server1 nginx-server2
docker network rm my-bridge-network
docker run -it -p 1001:1001 --name pp_container pp
docker run -it -p 1002:1002 --name pp_container2 pp2
docker run -it -p 8000:8000 --name pp_container4_slim pp4_slim
docker run -it -p 8001:8001 --name pp4_slim_less pp4_slim_less_package
docker build -t pp2 .
docker build -t pp4_slim .
docker build -t pp4_slim_less_package .
docker run -d -i -t bfe6792473b5 /bin/bash
docker exec -it bfe6792473b5 /bin/bash
ps -ef
docker run --name nginx-test -d -p 120:120 nginx
docker exec -it 775c7c9ee1e1 /bin/bash
docker cp :/file/path/within/container /host/path/target
docker cp 30455a37c745:/ C:/Users/Z13073219/Desktop/new
docker cp filename :/file/path/within/container
docker cp C:/Users/Z13073219/Desktop/new/test.txt 30455a37c745:/
docker cp nginx_test2:/etc/nginx/nginx.conf /usr/local/docker/nginx/conf/nginx.conf
docker cp nginx_test2:/etc/nginx/conf.d /usr/local/docker/nginx/conf/conf.d
docker run --name nginx-test -p 8022:8022 -d nginx
docker run --name nginx-test82 -p 82:80 -d nginx
server{
listen 81;
charset utf-8;
server_name localhost;
location / {
proxy_pass http://localhost:8000;
proxy_redirect default;
}
}
docker run --name nignx82 -p 82:80 -d nginx
docker container exec -it nignx82 /bin/bash
docker container cp nignx82:/ C:/Users/Z13073219/Desktop/nginx82
docker container cp C:/Users/Z13073219/Desktop/nginx82/etc/nginx/conf.d/default.conf nignx82:/etc/nginx/conf.d/default.conf
docker stop nignx82
docker start nignx82
docker restart nignx82
删除文件夹:
例如:删除/etc/nginx/log目录以及其下所有文件、文件夹
rm -rf /etc/nginx/log
删除文件:
例如:强制删除/etc/nginx/log/access.log文件
rm -f /etc/nginx/log/access.log
docker commit -m “nginx82_modified_ip” nignx82 nignx:v2
docker run --name nignx82_v2 -p 83:80 -d nignx:v2
docker run --name nignx82_v284 -p 84:80 -d nignx:v2
#建立数据卷
docker volume create container-vol
#查看数据卷位置方便挂靠到容器
docker volume ls
docker volume inspect container-vol
[
{
“CreatedAt”: “2022-02-24T23:18:29Z”,
“Driver”: “local”,
“Labels”: {},
“Mountpoint”: “/var/lib/docker/volumes/container-vol/_data”,
“Name”: “container-vol”,
“Options”: {},
“Scope”: “local”
}
]
#将数据卷挂靠到容器
docker run --name nginx_vol_container -dit -p 82:80 -v container-vol:/volume_opt/vol nginx bash
#进入容器进行查看
docker exec -it 8a16339b66e3 bin/bash
ls