在Linux中,可以通过以下几种方式配置和管理容器技术:
- Docker:
- 安装Docker:sudo apt install docker.io
- 启动Docker服务:sudo systemctl start docker
- 拉取镜像:docker pull ubuntu:18.04
- 运行容器:docker run -it ubuntu:18.04 /bin/“`
- 停止容器:docker stop
- 查看容器:docker ps
例如:
# 安装Docker
sudo apt install docker.io
# 启动Docker
sudo systemctl start docker
# 拉取ubuntu镜像
docker pull ubuntu:18.04
# 运行容器
docker run -it ubuntu:18.04 /bin/```
# 停止容器
docker stop c9f372ad70b6
# 查看运行容器
docker ps
- LXC(Linux Containers):
- 安装LXC:sudo apt install lxc lxd
- 初始化LXC:sudo lxd init
- 启动LXC服务:sudo systemctl start lxd
- 创建容器:lxc launch ubuntu:18.04 c1
- 列出容器:lxc list
- 进入容器:lxc exec c1 /bin/“`
- 停止容器:lxc stop c1
例如:
# 安装LXC
sudo apt install lxc lxd
# 初始化LXC
sudo lxd init
# 启动LXC
sudo systemctl start lxd
# 创建容器c1
lxc launch ubuntu:18.04 c1
# 列出容器
lxc list
# 进入容器c1
lxc exec c1 /bin/```
# 停止容器c1
lxc stop c1