虛擬機 === ## Sandbox ### 安裝 ``` sudo apt install schroot debootstrap #chroot用 sudo mkdir /var/chroot sudo vim #設定檔 /etc/schroot/schroot.conf [xenial] description=Ubuntu xenial type=directory directory=/var/chroot/xenial users=user1 #記得也要另外新增本機帳號sudo adduser user1 groups=sbuild root-groups=root preserve-environment=true ``` ### 部屬 sudo debootstrap --arch <ARCH> <VERSION> <DIRECTORY> <MIRROR> ``` sudo debootstrap --variant=buildd --arch amd64 xenial /var/chroot/xenial http://archive.ubuntu.com/ubuntu/ or sudo debootstrap --variant=buildd --arch i386 xenial /var/chroot/xenial http://archive.ubuntu.com/ubuntu/ ``` ### 進入系統 ``` sudo schroot -c xenial schroot -c xenial -u user1 (配合schroot.conf) 驗證 cat /etc/*-release apt list --installed | grep php sudo chroot /var/chroot/xenial 驗證 cat /etc/*-release apt list --installed | grep php apt update apt --no-install-recommends install wget debconf devscripts gnupg nano vim ``` #### 部屬 ``` sudo cp /etc/resolv.conf /var/chroot/xenial/etc/resolv.conf sudo cp /etc/apt/sources.list /var/chroot/xenial/etc/apt/ sudo vim /var/chroot/xenial/etc/apt/sources.list ``` ## Docker ### 安裝 ``` sudo apt update sudo apt upgrade sudo apt-get install docker.io ``` ### DOCKER Info ``` sudo docker version sudo docker info ifconfig docker0 //ip -c a ``` ### Docker Run ``` sudo docker run busybox echo "hello world" sudo docker run --name test busybox ping localhost sudo docker ps ``` ### Web Demo * -d:run指令的無數值參數,背景執行。 * --name web:run指令的文字參數,指定這個Container的名字為web。 * -p 8080:80:run指令的數值參數,把主機的8080通訊埠所有流量轉發到web這個Container的80通訊埠。 ``` sudo docker run -d --name web -p 8080:80 joshhu/webdemo sudo docker ps -a ``` ### Commit ``` sudo docker commit -m "myweb" {CONTAINER ID} myweb:v1 sudo docker run -d -p 8080:80 myweb:v1 /start.sh ``` ### Docker Remove ``` sudo docker ps -a sudo docker images #查看系統目前有的images sudo docker rm {CONTAINER ID} #刪除特定ID ``` ### 其他 ``` sudo docker stop {CONTAINER ID} sudo docker start {CONTAINER ID} sudo docker rm -f {CONTAINER ID} sudo docker rm $(sudo docker ps -a -q) #全部刪除 sudo docker rmi {IMAGE ID} ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up