Docker指令
docker
- docker kill <container id>
- docker ps
- docker restart <container id>
- docker start <container id>
- docker logs <container id>
- docker exec -it <container id>
- bash 進到<container id>container -it:互動模式 以bash
docker-machine
- docker-machine ls
Create image from container
- docker commit <container> <name>/<image>:<version>
將檔案cp至container內
- docker cp <filePath> <container>:<containerPath>
tunnel傳輸
-
ssh -L <tunnelPort>:<remoteIP>:<remotePort> <tunnelIP> (e.g. ssh -L 5566:192.168.34.94:22 me@192.168.12.34)
-
scp -P <tunnelPort> -r <localDir> <remoteAccount>@localhost:/home/cirrusdi/ (e.g. scp -P 5566 -r /Volumes/jetD_YD/work/cirrusdi/hstrade/code remote@localhost:/home/remote/hstrade/)
docker mount to container
- docker run -d -p 8787:8787 --name <name> -v <localDirPath>:/<rstudioPath>:ro -e USER=<user> -e PASSWORD=<pw> rocker/rstudio
VM中執行docker
-
sudo systemctl start docker
-
sudo systemctl status docker //確認有無執行
-
sudo systemctl enable docker //開機便執行
VM中設定user不需sudo指令
-
sudo groupadd docker //創建一個docker group
-
sudo usermod -aG docker <user> //加入user至docker group
匯出 docker image: docker commit and save (like push)
-
docker commit <container id> <author><imageName>:<version>
-
docker save -o [<save path>.tar] <author><imageName>:<version>