Linux本地部署deepseek大模型之 4. 安装docker容器
·
1. docker官网https://www.docker.com/
2.进入文档地址 https://docs.docker.com/?_gl=1*1vhh4fx*_gcl_au*MTk4ODYyNzg0Ny4xNzYxNDgyMTE0*_ga*MTI0NzkyNDk5OC4xNzYxNDgyMTE0*_ga_XJWPQMJYHQ*czE3NjE0ODIxMTQkbzEkZzEkdDE3NjE0ODIyMTgkajU5JGwwJGgw
3.按照文档中的说明执行命令安装dockerhttps://docs.docker.com/manuals/
root@VM-0-16-ubuntu:/usr/java/jdk-21# # Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
### 执行安装命令终端的输出...
Hit:1 http://mirrors.tencentyun.com/ubuntu jammy InRelease
...
Reading state information... Done
...
After this operation, 24.6 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.tencentyun.com/ubuntu jammy-updates/main amd64 ca-certificates all 20240203~22.04.1 [162 kB]
...
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
Get:1 https://download.docker.com/linux/ubuntu jammy InRelease [48.5 kB]
...
Get:5 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [58.1 kB]
Fetched 235 kB in 3s (89.1 kB/s)
Reading package lists... Done
### 安装docker
root@VM-0-16-ubuntu:/usr/java/jdk-21# sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
docker-ce-rootless-extras libslirp0 pigz slirp4netns
......
After this operation, 437 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://download.docker.com/linux/ubuntu jammy/stable amd64 containerd.io amd64 1.7.28-1~ubuntu.22.04~jammy [31.9 MB]
...
Fetched 105 MB in 8s (13.2 MB/s)
Selecting previously unselected package containerd.io.
No user sessions are running outdated binaries.
...
No VM guests are running outdated hypervisor (qemu) binaries on this host.
### 查看docker是否运行
root@VM-0-16-ubuntu:/usr/java/jdk-21# sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2025-10-26 20:50:30 CST; 1min 1s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 174641 (dockerd)
Tasks: 10
Memory: 21.7M
CPU: 368ms
CGroup: /system.slice/docker.service
└─174641 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
...
Oct 26 20:50:30 VM-0-16-ubuntu systemd[1]: Started Docker Application Container Engine.
..
lines 1-22/22 (END)
root@VM-0-16-ubuntu:/usr/java/jdk-21# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
17eec7bbc9d7: Pull complete
Digest: sha256:56433a6be3fda188089fb548eae3d91df3ed0d6589f7c2656121b911198df065
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/
...
Run 'docker COMMAND --help' for more information on a command.
For more help on how to use Docker, head to https://docs.docker.com/go/guides/
### 查看docker的版本
root@VM-0-16-ubuntu:/usr/java/jdk-21# docker -v
Docker version 28.5.1, build e180ab8
root@VM-0-16-ubuntu:/usr/java/jdk-21# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 1b44b5a3e06a 2 months ago 10.1kB
### 设置docker 开机自启动
root@VM-0-16-ubuntu:/usr/java/jdk-21# systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
##停止docker
root@VM-0-16-ubuntu:/usr/java/jdk-21# systemctl stop docker
Warning: Stopping docker.service, but it can still be activated by:
docker.socket
###重启docker
root@VM-0-16-ubuntu:/usr/java/jdk-21# systemctl restart docker
###接下来使用docker安装mysql
### 使用docker 拉取镜像
root@VM-0-16-ubuntu:/usr/java/jdk-21# docker pull mysql:8.4.4
8.4.4: Pulling from library/mysql
cea172a6e83b: Pull complete
...
Status: Downloaded newer image for mysql:8.4.4
docker.io/library/mysql:8.4.4
### 查看docker中是否已经有mysql镜像
root@VM-0-16-ubuntu:/usr/java/jdk-21# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 1b44b5a3e06a 2 months ago 10.1kB
mysql 8.4.4 4a8a163431d3 9 months ago 769MB
###
root@VM-0-16-ubuntu:~# cd /home
root@VM-0-16-ubuntu:/home# ll
## 创建目录 用于安装mysql
root@VM-0-16-ubuntu:/home# mkdir mysql8
root@VM-0-16-ubuntu:/home# ls
mysql8 ubuntu
root@VM-0-16-ubuntu:/home# cd mysql8/
root@VM-0-16-ubuntu:/home/mysql8# pwd
/home/mysql8
root@VM-0-16-ubuntu:/home/mysql8# ll
total 8
drwxr-xr-x 2 root root 4096 Oct 26 21:18 ./
drwxr-xr-x 4 root root 4096 Oct 26 21:18 ../
root@VM-0-16-ubuntu:/home/mysql8# mkdir mysql-files
root@VM-0-16-ubuntu:/home/mysql8# mkdir data
root@VM-0-16-ubuntu:/home/mysql8# mkdir log
root@VM-0-16-ubuntu:/home/mysql8# mkdir conf
root@VM-0-16-ubuntu:/home/mysql8# ll
total 24
drwxr-xr-x 6 root root 4096 Oct 26 21:20 ./
drwxr-xr-x 4 root root 4096 Oct 26 21:18 ../
drwxr-xr-x 2 root root 4096 Oct 26 21:20 conf/
drwxr-xr-x 2 root root 4096 Oct 26 21:20 data/
drwxr-xr-x 2 root root 4096 Oct 26 21:20 log/
drwxr-xr-x 2 root root 4096 Oct 26 21:19 mysql-files/
root@VM-0-16-ubuntu:/home/mysql8# cd conf/
root@VM-0-16-ubuntu:/home/mysql8/conf# pwd
/home/mysql8/conf

更多推荐
所有评论(0)