Docker:修订间差异
跳到导航
跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
(→範例) |
|||
第38行: | 第38行: | ||
== 範例 == | == 範例 == | ||
啟動一個簡單的[[Ubuntu]]環境: | 啟動一個簡單的[[Ubuntu]]環境: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
docker run -i -t --rm ubuntu:latest /bin/bash | docker run -i -t --rm ubuntu:latest /bin/bash | ||
</syntaxhighlight> | |||
或是特定版本: | |||
<syntaxhighlight lang="bash"> | |||
docker run -i -t --rm ubuntu:jammy /bin/bash | |||
</syntaxhighlight> | </syntaxhighlight> | ||
然後把APT的伺服器換掉: | 然後把APT的伺服器換掉: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
perl -pi -e 's/archive.ubuntu.com/tw.archive.ubuntu.com/g' /etc/apt/sources.list | perl -pi -e 's/archive.ubuntu.com/tw.archive.ubuntu.com/g' /etc/apt/sources.list | ||
第50行: | 第59行: | ||
裝些簡單的東西: | 裝些簡單的東西: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
apt install -y curl vim-nox wget | apt install -y curl vim-nox wget |
2022年10月17日 (一) 01:51的版本
Docker是一套提供容器(英语:Container)的软体。
安装
可以用这个一行指令直接安装:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -; echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list; sudo apt update; sudo apt install -y docker-ce; sudo apt clean
另外arm64的平台可以这样安装:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -; echo "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list; sudo apt update; sudo apt install -y docker-ce; sudo apt clean
docker compose(docker-compose)
另外可以加装docker compose(docker-compose)套件:
sudo apt install -y docker-compose-plugin
可以这样使用:
docker compose
docker-machine
目前已经deprecated[1]。没有套件可以装,直接安装binary[2]:
base=https://github.com/docker/machine/releases/download/v0.16.2 && curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine && sudo mv /tmp/docker-machine /usr/local/bin/docker-machine && chmod +x /usr/local/bin/docker-machine
范例
启动一个简单的Ubuntu环境:
docker run -i -t --rm ubuntu:latest /bin/bash
或是特定版本:
docker run -i -t --rm ubuntu:jammy /bin/bash
然后把APT的伺服器换掉:
perl -pi -e 's/archive.ubuntu.com/tw.archive.ubuntu.com/g' /etc/apt/sources.list
apt update -y
装些简单的东西:
apt install -y curl vim-nox wget
常用指令
docker system prune
参考文献
- ↑ Docker Machine is now in maintenance mode #4537. [2022-07-13] (English).
- ↑ Install Docker Machine | Docker Documentation. [2021-07-21] (English).