0
点赞
收藏
分享

微信扫一扫

【论文速读】| 对大语言模型解决攻击性安全挑战的实证评估

上善若水的道 03-31 16:30 阅读 1

ubuntu18.04安装docker 并修改其默认路径

0 删除已有docker

sudo apt-get remove docker docker-engine docker.io containerd runc

1 使用 Docker 仓库进行docker安装

两个方法可以较差借鉴用

方法一(实测成功):

参考链接:https://www.runoob.com/docker/ubuntu-docker-install.html

# 更新 apt 包索引
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
    
# 添加 Docker 的官方 GPG 密钥
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

# 验证您现在是否拥有带有指纹的密钥
sudo apt-key fingerprint 0EBFCD88

# 使用以下指令设置稳定版仓库
sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
  $(lsb_release -cs) \
  stable"
  
# 更新 apt 包索引
sudo apt-get update

# 安装最新版本的 Docker Engine-Community 和 containerd 
sudo apt-get install docker-ce docker-ce-cli containerd.io

# 测试 Docker 是否安装成功,输入以下指令,打印出以下信息则安装成功:
sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                                                                                                                                  Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest


Hello from Docker!
This message shows that your installation appears to be working correctly.


To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.


To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash


Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/


For more examples and ideas, visit:
 https://docs.docker.com/get-started/

方法二(官方版本):

参考链接:https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

# Install the Docker packages
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# 测试 Docker 是否安装成功,输入以下指令,打印出以下信息则安装成功:
sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                                                                                                                                  Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest


Hello from Docker!
This message shows that your installation appears to be working correctly.


To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.


To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash


Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/


For more examples and ideas, visit:
 https://docs.docker.com/get-started/

2 修改默认路径

# 确认当前的docker存储位置
docker info

# 停止docker服务
systemctl stop docker

# 停止docker服务
systemctl stop docker

# 创建drop-in目录和drop-in文件
mkdir /etc/systemd/system/docker.service.d
touch /etc/systemd/system/docker.service.d/docker.conf
echo "[Service]">>/etc/systemd/system/docker.service.d/docker.conf
echo "ExecStart=">>/etc/systemd/system/docker.service.d/docker.conf
echo "ExecStart=/usr/bin/dockerd --data-root="/mnt/data/docker" --storage-driver=overlay2">>/etc/systemd/system/docker.service.d/docker.conf
# /mnt/data/docker是新的存储位置,而overlay2是当前docker所使用的存储驱动。

# 重新加载服务守护程序和启动docker服务
systemctl daemon-reload
systemctl start docker

# 修改结果确认
docker info
# 检查Server下的Docker Root Dir标记,显示的路径应该是新的docker镜像和容器存储位置,如本例的/mnt/data/docker。

注:

在 docker 19.xx 版本以后使用 data-root 来代替 graph 可以在 /etc/docker/daemon.json 中配置,也可以在 docker.service 中修改,效果一样。修改完成后 daemon-reload 一下然后 restart docker

参考链接

  • https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

  • https://www.runoob.com/docker/ubuntu-docker-install.html

  • https://blog.csdn.net/u010227042/article/details/129472825?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0-129472825-blog-108221250.235v38pc_relevant_sort_base3&spm=1001.2101.3001.4242.1&utm_relevant_index=3

  • https://blog.csdn.net/a772304419/article/details/121244400

举报

相关推荐

0 条评论