赞
踩
python+vue3+fastapi+ai 学习_浪淘沙jkp的博客-CSDN博客https://blog.csdn.net/jiangkp/category_12623996.html
docker安装起来比较方便,不影响系统整体,和前面虚拟环境有异曲同工之妙,今天把老笔记本T400拿出来装了个ubuntu24.04 跑起来还可以,6g的内存,跑个mysql和redis应该问题不大,启动好算好,没有占用大的资源,如果前面选择那个最小化安装,估计更省资源
victor_t400@victort400:~$ sudo apt update
victor_t400@victort400:~$ sudo apt install docker.io
Could not connect to cn.archive.ubuntu.com:80 (45.125.0.6). - connect (111: Connection refused) Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable)
这是系统安装时候没有换源啊,也许吧
victor_t400@victort400:~$ sudo cp /etc/apt/sources.list /etc/apt/sources_default.list
victor_t400@victort400:~$ sudo vi /etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse # deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
sudo apt install docker.io
如果找不到软件包
sudo apt update
就可以了
默认情况下,运行 Docker 命令需要管理员权限。为了避免这种情况,您可以将您的用户添加到 Docker 组。
victor_t400@victort400:~$ sudo usermod -aG docker ${USER}
重启后生效(反正我重启了)
查看版本
victor_t400@victort400:~$ docker version
Client:
Version: 24.0.7
API version: 1.43
Go version: go1.22.2
Git commit: 24.0.7-0ubuntu4
Built: Wed Apr 17 20:08:25 2024
OS/Arch: linux/amd64
Context: defaultServer:
Engine:
Version: 24.0.7
API version: 1.43 (minimum version 1.12)
Go version: go1.22.2
Git commit: 24.0.7-0ubuntu4
Built: Wed Apr 17 20:08:25 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.12
GitCommit:
runc:
Version: 1.1.12-0ubuntu3
GitCommit:
docker-init:
Version: 0.19.0
检查用户是否属于Docker组:
victor_t400@victort400:~$ id ${USER}
uid=1000(victor_t400) gid=1000(victor_t400) groups=1000(victor_t400),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),101(lxd),110(docker)
victor_t400@victort400:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:a26bff933ddc26d5cdf7faa98b4ae1e3ec20c4985e6f87ac0973052224d24302
Status: Downloaded newer image for hello-world:latest
victor_t400@victort400:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a18ad488d054 hello-world "/hello" 2 minutes ago Exited (0) 2 minutes ago elegant_edison
通过执行这些步骤,您应该已经在 Ubuntu 24.04 系统上成功安装了 Docker。此设置允许您开始使用 Docker(现代软件开发中的关键工具)构建和部署容器化应用程序。享受探索 Docker 提供的巨大功能!
查看运行的,目前没有
victor_t400@victort400:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
查看全部,包括已经停止运行的
victor_t400@victort400:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a18ad488d054 hello-world "/hello" 2 minutes ago Exited (0) 2 minutes ago elegant_edison
b、查看日志
docker logs [容器名 | 容器ID ]
docker logs -f [容器名 | 容器ID ] #表示实时的跟踪日志输出
docker logs --since 30m myredis # 此处 --since 30m 是查看此容器30分钟之内的日志情况。
docker exec -it [容器名 | 容器ID] bash
-d :分离模式: 在后台运行
-i :即使没有附加也保持STDIN 打开
-t :分配一个伪终端
用到什么应用,网上查什么吧
docker stop [容器名|容器ID] #停止容器
docker start [容器名|容器ID] #启动停止的容器
docker restart [容器名|容器ID] # 将容器重新启动
docker kill [容器名|容器ID] #强行终止
docker rm [容器名|容器ID] # 删除停止的容器
注意点:
docker search redis #查找公开仓库中的redis镜像,最新的
docker pull redis[:tag] #拉取镜像
docker rmi redis[:tag] #删除镜像
docker images #查看所有的镜像
注意:拉取镜像不加版本号一般就是最新的
由于redis安装和mysql安装我想已几种方式安装,所以先参考大佬们的文章,研究一下,后续再写
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。