20250201 - 一键安装 Docker - 一键安装 Docker 的命令 - 经验交流 - 零度社区¶
- 分类:
Clippings - 创建:
2025-02-01 - 标签:
Docker, 安装, 一键安装, 命令, 操作系统
一键安装 Docker 的命令 - 经验交流 - 零度社区¶
curl -fsSL https://get.docker.com | sh sudo systemctl enable --now docker
To enable Docker access for a user in Ubuntu, you need to add the user to the docker group. This allows the user to run Docker commands without needing to use sudo. Here are the steps to do this:
Step 1: Create the Docker Group (if it doesn't exist)¶
Most installations of Docker will automatically create a docker group. You can check if it exists with the following command:
If the group does not exist, you can create it using:
Step 2: Add the User to the Docker Group¶
Replace username with the actual username of the user you want to grant Docker access to:
Step 3: Log Out and Log Back In¶
For the group changes to take effect, the user needs to log out and then log back in. Alternatively, you can use the following command to apply the changes without logging out:
Step 4: Verify Docker Access¶
After logging back in, you can verify that the user has Docker access by running:
This command will download and run a test image from Docker Hub. If everything is set up correctly, you should see a message indicating that Docker is working.
Note¶
If you encounter any issues, make sure that Docker is installed correctly and the Docker service is running. You can start the Docker service with the following command:
You can also enable it to start on boot:
That's it! The user should now have access to run Docker commands without needing to use sudo.