一,具体操作
docker run -d -v D:/wamp/www:/www/wwwroot --name test_centos -p 80:80 -p 8888:8888 -p 888:888 -p 443:443 -p 20:20 -p 21:21 -p 3306:3306 -p 6379:6379 --restart=always -itd cxn9122/centos_2:latest
注:test_centos 可以随便取名 , cxn9122/centos_2 (本地镜像NAME) latest(本地镜像TAG) , D:/wamp/www (本地目录) /www/wwwroot (docker容器目录)
二,若容器已经启动,需要更改端口映射,
-
docker stop container01 (container01:容器名称)
-
docker commit container01 new_image:tag (new_image:镜像名称 ,tag:镜像TAG)
-
docker run --name container02 -p 80:80 -itd new_image:tag (container02:新容器名称,)
三,进入容器终端,
docker exec -it 4db4a3ead1a0 bash (4db4a3ead1a0:容器ID)