在ubuntu server中安装和配置docker
经过一段时间针对不同版本的学习,现在总结当前最新的安装配置过程(应该也是比较简单的)
如果不清楚什么是docker,请参考 https://www.docker.com/
准备工作
建议在安装之前运行下面的命令对ubuntu server进行更新
sudo apt-get update
sudo apt-get upgrade
安装docker
其实应该只要一句指令即可
wget –qO- https://get.docker.com/ | sh
请注意,这里的-q后面跟的是大写的O字母
按理说是可以通过apt-get install docker.io这样的方式来安装的,但可能不是最新的,所以最保险的方式就是用上面的命令
安装成功后,会显示出来下面的输出结果
验证docker安装
通过docker version 检查版本,你可能会遇到下面的提示
这是因为当前用户的权限方面的问题,可以将当前用户加入docker这个group
sudo gpasswd –a ${USER} docker
例如下面这样
chenxizhang@ubuntu:~$ sudo gpasswd -a ${USER} docker Adding user chenxizhang to group docker
然后重新启动docker 服务
chenxizhang@ubuntu:~$ sudo service docker restart docker stop/waiting docker start/running, process 10014
再次运行docker version,你可能还是会遇到刚才同样的错误
chenxizhang@ubuntu:~$ docker version
Client:
Version: 1.8.2
API version: 1.20
Go version: go1.4.2
Git commit: 0a8c2e3
Built: Wed Oct 7 17:48:28 UTC 2015
OS/Arch: linux/amd64
Get http:///var/run/docker.sock/v1.20/version: dial unix /var/run/docker.sock: permission denied.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?
这时,你需要做的是重新启动服务器
sudo reboot
再次登陆的时候,就可以正常显示版本信息,表示一切都正常了
chenxizhang@ubuntu:~$ docker version Client: Version: 1.8.2 API version: 1.20 Go version: go1.4.2 Git commit: 0a8c2e3 Built: Wed Oct 7 17:48:28 UTC 2015 OS/Arch: linux/amd64 Server: Version: 1.8.2 API version: 1.20 Go version: go1.4.2 Git commit: 0a8c2e3 Built: Wed Oct 7 17:48:28 UTC 2015 OS/Arch: linux/amd64
享受docker吧
chenxizhang@ubuntu:~$ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 535020c3e8ad: Pull complete af340544ed62: Pull complete Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c 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. 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 Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/userguide/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· winform 绘制太阳,地球,月球 运作规律
· 上周热点回顾(3.3-3.9)
2010-10-11 Workflow Foundation 4.0中的事件驱动流程设计和应用(五)
2009-10-11 正确地使用投影仪和移动硬盘