1. 下载地址
选择这个完整版,可以连containerd一起安装。

2. 安装
| [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 |
| |
| cp ./bin/* /usr/local/bin |
| cp -ra ./lib/systemd/system/* /etc/systemd/system/ |
| # systemctl enable buildkit containerd |
| # systemctl restart buildkit containerd |
| # systemctl status buildkit containerd |
| [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命令几乎相同,举几常用的命令做例子
| [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) |
| |
| [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 |
| [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 |
| [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 |
| |
| [root@liubei-02 ~]# nerdctl run -d -p 1840:1840 --name crow-qin harbocto.boe.com.cn/crow/crow-qin |
| b61ea892800e970b9a21279943342309b5b9496ff82a8fe8e50c9216b041ca94 |
| 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 |
| [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 |
| [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
| version: "3" |
| services: |
| crow_qin: |
| image: harbocto.boe.com.cn/crow/crow-qin |
| ports: |
| - 1840:1840 |
| restart: always |
| [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 |
| [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 |
| [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 |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| [root@liubei-02 crow-qin]# nerdctl compose down |
| INFO[0000] Removing container crow-qin_crow_qin_1 |
| INFO[0000] Removing network crow-qin_default |

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了