nerdctl替代docker及docker-compose的安装使用
GPT4.0+Midjourney绘画+国内大模型 会员永久免费使用!
【 如果你想靠AI翻身,你先需要一个靠谱的工具! 】
1 下载
下载地址
url https://github.com/containerd/nerdctl/releases/
选择安装包
选择这个完整版,可以连containerd一起安装。
2 安装
- 解压缩得到一下四个目录
1 2 3 4 5 | [root@liubei-02 nerdctl-full-1.0.0] # ll drwxr-xr-x 2 root root 4096 10月 21 21:28 bin drwxr-xr-x 3 root root 21 10月 21 21:27 lib drwxr-xr-x 3 root root 17 10月 21 21:27 libexec drwxr-xr-x 3 root root 17 10月 21 21:22 share |
- 拷贝二进制文件
- 拷贝启动文件
- 启动和开机启动
1 2 3 | # systemctl enable buildkit containerd # systemctl restart buildkit containerd # systemctl status buildkit containerd |
- cni 插件
1 2 | [root@liubei-02 nerdctl-full-1.2.1] # makedir /opt/cni/bin [root@liubei-02 nerdctl-full-1.2.1] # cp -ra ./libexec/cni/* /opt/cni/bin/ |
3 替代docker
和docker命令几乎相同,举几常用的命令做例子
- 下载镜像
1 2 3 4 5 6 7 8 9 | [root@liubei-02 nerdctl-full-1.2.1] # nerdctl pull harbocto.boe.com.cn/crow/crow-qin harbocto.boe.com.cn /crow/crow-qin :latest: resolved |++++++++++++++++++++++++++++++++++++++| manifest-sha256:5891ae5e691914196af46e869a6cba45c6e53266b4110b85c5c37385cc3b6b84: done |++++++++++++++++++++++++++++++++++++++| config-sha256:04f135a90290c42b8cf9b52395c04753b4d9ed48ddae7c714a0eccdf8acd9682: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:b042f1415af977fb7da4d48f6668fad99add49542a1e01eb14f52a5e55338e54: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:31603596830fc7e56753139f9c2c6bd3759e48a850659506ebfb885d1cf3aef5: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:b0faaf7e563984a940329fd6098b28ecec4309b30990df5b9f7f1618f7f585bf: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:3c6f0abee76a3b1cde1a485efdc7d2f09d2023c61736f6d862b23d94a3bd0f6e: done |++++++++++++++++++++++++++++++++++++++| elapsed: 0.9 s total: 17.7 M (19.6 MiB /s ) |
- 查看镜像
1 2 3 4 | [root@liubei-02 nerdctl-full-1.2.1] # nerdctl images REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE harbocto.boe.com.cn /crow/crow-qin latest 5891ae5e6919 34 seconds ago linux /amd64 39.6 MiB 17.7 MiB harbocto.boe.com.cn /public/mysql 5.7 9e02c7c9a87d 26 minutes ago linux /amd64 428.5 MiB 143.5 MiB |
- 镜像打tag
1 2 3 4 5 6 | [root@liubei-02 crow-qin] # nerdctl tag harbocto.boe.com.cn/crow/crow-qin harbocto.boe.com.cn/crow/crow-qin:0327 [root@liubei-02 crow-qin] # nerdctl images REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE harbocto.boe.com.cn /crow/crow-qin 0327 5891ae5e6919 4 seconds ago linux /amd64 39.6 MiB 17.7 MiB harbocto.boe.com.cn /crow/crow-qin latest 5891ae5e6919 4 hours ago linux /amd64 39.6 MiB 17.7 MiB harbocto.boe.com.cn /public/mysql 5.7 9e02c7c9a87d 4 hours ago linux /amd64 428.5 MiB 143.5 MiB |
- 删除镜像
1 2 3 4 5 6 7 8 9 10 | [root@liubei-02 crow-qin] # nerdctl rmi harbocto.boe.com.cn/crow/crow-qin:0327 Untagged: harbocto.boe.com.cn /crow/crow-qin :0327@sha256:5891ae5e691914196af46e869a6cba45c6e53266b4110b85c5c37385cc3b6b84 Deleted: sha256:89ae5c4ee501a09c879f5b58474003539ab3bb978a553af2a4a6a7de248b5740 Deleted: sha256:4e8c762c91062b88c9c07813b2cf0795d81401dd0fb0c19bed291901dd4f1cbd Deleted: sha256:248001ffdc3a1a316501cd5b435bf6346fa6ddd88acecd90cff9cc08f5e2b3ed Deleted: sha256:bbd2fde7f96c461ee59290dc20dc461036e1288f6e7e88c805aa2d1619c1c0c6 [root@liubei-02 crow-qin] # nerdctl images REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE harbocto.boe.com.cn /crow/crow-qin latest 5891ae5e6919 4 hours ago linux /amd64 39.6 MiB 17.7 MiB harbocto.boe.com.cn /public/mysql 5.7 9e02c7c9a87d 4 hours ago linux /amd64 428.5 MiB 143.5 MiB |
- 启动容器
1 2 | [root@liubei-02 ~] # nerdctl run -d -p 1840:1840 --name crow-qin harbocto.boe.com.cn/crow/crow-qin b61ea892800e970b9a21279943342309b5b9496ff82a8fe8e50c9216b041ca94 |
- 查看容器
1 2 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b61ea892800e harbocto.boe.com.cn /crow/crow-qin :latest "/crow-qin" About a minute ago Up 0.0.0.0:1840->1840 /tcp crow-qin |
- 停止容器
1 2 3 4 5 | [root@liubei-02 ~] # nerdctl stop crow-qin crow-qin [root@liubei-02 ~] # nerdctl ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b61ea892800e harbocto.boe.com.cn /crow/crow-qin :latest "/crow-qin" 2 minutes ago Exited (2) 15 seconds ago 0.0.0.0:1840->1840 /tcp crow-qin |
- 删除容器
1 2 3 4 | [root@liubei-02 ~] # nerdctl rm crow-qin crow-qin [root@liubei-02 ~] # nerdctl ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
4 替代docker-compose
- docker-compose.yml文件如下
1 2 3 4 5 6 7 | version: "3" services: crow_qin: image: harbocto.boe.com.cn /crow/crow-qin ports: - 1840:1840 restart: always |
- 启动容器
1 2 3 4 | [root@liubei-02 crow-qin] # nerdctl compose up -d INFO[0000] Creating network crow-qin_default INFO[0000] Ensuring image harbocto.boe.com.cn /crow/crow-qin INFO[0000] Creating container crow-qin_crow_qin_1 |
- 查看结果
1 2 3 | [root@liubei-02 crow-qin] # nerdctl ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a0ebebf7bb9d harbocto.boe.com.cn /crow/crow-qin :latest "/crow-qin" 12 seconds ago Up 0.0.0.0:1840->1840 /tcp crow-qin_crow_qin_1 |
- 查看日志
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | [root@liubei-02 crow-qin] # nerdctl compose logs -f crow_qin_1 |&{MysqlConf:{MysqlIp:10.10.239.136 MysqlPort:3306 DbName:crow MysqlUser:root MysqlPassword:1234} RedisConf:{RidesIp:10.10.239.136 RidesPort:6379 RidesDbNum:2 RidesPassword: "" }} crow_qin_1 |2023-03-27 13:40:48.649648 INFO config /connect_mysql .go:48 数据库链接成功 crow_qin_1 |2023-03-27 13:40:48.649728 INFO config /connect_redis .go:19 Redis<10.10.239.136:6379 db :2> crow_qin_1 |2023-03-27 13:40:48.650863 INFO cache /example .go:51 OK crow_qin_1 |2023-03-27 13:40:48.650873 INFO cache /example .go:53 redis 链接成功 crow_qin_1 |OK crow_qin_1 |[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. crow_qin_1 | crow_qin_1 |[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. crow_qin_1 | - using env : export GIN_MODE=release crow_qin_1 | - using code: gin.SetMode(gin.ReleaseMode) crow_qin_1 | crow_qin_1 |[GIN-debug] GET /swagger/ *any --> github.com /swaggo/gin-swagger .CustomWrapHandler.func1 (3 handlers) crow_qin_1 |[GIN-debug] GET /api/v1/ping --> crow-qin /src/router .Ping (3 handlers) crow_qin_1 |[GIN-debug] GET /api/v1/version --> crow-qin /src/router .Version (3 handlers) crow_qin_1 |[GIN-debug] GET /api/v1/liubei --> crow-qin /src/router .LiuBei (3 handlers) crow_qin_1 |[GIN-debug] POST /api/v1/login --> crow-qin /src/router .Login (3 handlers) crow_qin_1 |[GIN-debug] POST /api/v1/login/refresh --> crow-qin /src/router .Refresh (3 handlers) crow_qin_1 |[GIN-debug] POST /api/v1/admin/user --> crow-qin /src/router .CreateUser (4 handlers) crow_qin_1 |[GIN-debug] PUT /api/v1/admin/user-password --> crow-qin /src/router .ResetUserPassword (4 handlers) crow_qin_1 |[GIN-debug] GET /api/v1/admin/users --> crow-qin /src/router .GetUsers (4 handlers) crow_qin_1 |[GIN-debug] GET /api/v1/admin/users/ :uuid --> crow-qin /src/router .GetUser (4 handlers) crow_qin_1 |[GIN-debug] DELETE /api/v1/admin/users/ :uuid --> crow-qin /src/router .DeleteUser (4 handlers) crow_qin_1 |[GIN-debug] PUT /api/v1/admin/users --> crow-qin /src/router .UpdateUsersInfo (4 handlers) crow_qin_1 |[GIN-debug] PUT /api/v1/user/info --> crow-qin /src/router .UpdateUserInfo (4 handlers) crow_qin_1 |[GIN-debug] PUT /api/v1/user/password --> crow-qin /src/router .UpdateUserPassword (4 handlers) crow_qin_1 |[GIN-debug] GET /api/v1/user/info --> crow-qin /src/router .GetUserInfo (4 handlers) crow_qin_1 |[GIN-debug] GET / --> crow-qin /src/router .ServerRouter.func1 (3 handlers) crow_qin_1 |[GIN-debug] GET /js/ *filepath --> github.com /gin-gonic/gin .(*RouterGroup).createStaticHandler.func1 (3 handlers) crow_qin_1 |[GIN-debug] HEAD /js/ *filepath --> github.com /gin-gonic/gin .(*RouterGroup).createStaticHandler.func1 (3 handlers) crow_qin_1 |[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value. crow_qin_1 |Please check https: //pkg .go.dev /github .com /gin-gonic/gin #readme-don-t-trust-all-proxies for details. crow_qin_1 |[GIN-debug] Listening and serving HTTP on :1840 |
- 关闭容器
1 2 3 | [root@liubei-02 crow-qin] # nerdctl compose down INFO[0000] Removing container crow-qin_crow_qin_1 INFO[0000] Removing network crow-qin_default |
以上就是nerdctl替代docker及docker-compose的安装使用的详细内容,更多关于nerdctl替代docker的资料请关注脚本之家其它相关文章!
微信公众号搜索 “ 脚本之家 ” ,选择关注
程序猿的那些事、送书等活动等着你
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请将相关资料发送至 reterry123@163.com 进行投诉反馈,一经查实,立即处理!
相关文章
docker swarm如何在指定的node上运行指定的容器
这篇文章主要介绍了docker swarm如何在指定的node上运行指定的容器,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2018-07-07docker镜像仓库hub.docker.com无法访问的解决方法
最近许多群友都询问为什么无法访问Docker镜像仓库,本文就来介绍一下docker镜像仓库hub.docker.com无法访问的解决方法,感兴趣的可以了解一下2023-08-08
最新评论