首页 > 系统相关 >Ubuntu安装docker详细教程

Ubuntu安装docker详细教程

时间:2023-03-07 18:57:11浏览次数:52  
标签:教程 -- sudo apt && Ubuntu docker restart

1.安装

sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" && sudo apt-get update && sudo apt-get install -y docker-ce

为了避免每次命令都输入sudo,可以设置用户权限(将当前用户添加到docker组里面),注意执行后须注销重新登录

sudo usermod -a -G docker $USER

2. 启动与停止

安装完成Docker后,默认已经启动了docker服务,如需手动控制docker服务的启停,可执行如下命令

# 启动docker
sudo service docker start

# 停止docker
sudo service docker stop

# 重启docker
sudo service docker restart

3.配置镜像加速器

针对Docker客户端版本大于 1.10.0 的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker && sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://epsax6ut.mirror.aliyuncs.com"],
  "log-driver":"json-file",
  "log-opts": {"max-size":"10m", "max-file":"3"}
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

参考阿里云的docker安装文档https://developer.aliyun.com/article/110806

4.安装常用软件

(1).MySQL

docker pull mysql:5.7.36 && docker run --name mysql5.7.36 --restart=always -p 3306:3306 -e MYSQL_ROOT_PASSWORD=你的密码 -d mysql:5.7.36 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

(2).MongoDB

docker pull mongo:5.0.5 && docker run -d --name mongo5.0.5 --restart=always -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=用户名 -e MONGO_INITDB_ROOT_PASSWORD=密码 mongo:5.0.5

(3).Redis

docker pull redis:6.2.6-alpine && docker run --name redis6.2.6 --restart=always -d redis:6.2.6-alpine

(4).Nginx

docker pull nginx:1.20.2-alpine

(5).PostgreSQL

docker pull postgres:14.2-alpine && docker run --name postgres14.2 --restart=always -p 5432:5432 -e POSTGRES_PASSWORD=你的密码 -d postgres:14.2-alpine

标签:教程,--,sudo,apt,&&,Ubuntu,docker,restart
From: https://www.cnblogs.com/lidabo/p/17189162.html

相关文章

  • Docker-Desktop 修改已运行容器端口
    在翻阅了很多文章后,都是说Linux修改绑定的。自己找了WSL的Ubuntu也没找到。翻阅了一大堆文章找到了相关解决方案,作此记录。参阅文档https://www.wuleba.com/555.ht......
  • Ubuntu 通过 docker 运行 redis
    1、首先拉取redis的镜像dockerpullredis2、运行redis容器dockerrun--nameredis-p6379:6379-dredis--nameredis#容器实例的名称-p6......
  • ubuntu16.04 pip3显示已经安装,但是用的时候却又显示未安装
    pip3显示未安装我装行吧?What?已装?再试一遍pip3-version,结果还是老样子吐血!好吧,我脚本安装,行了吧输入wgethttps://bootstrap.pypa.io/get-pip.py接着输......
  • 【WPS JS教程】判断单元格是否为空值
    functionisUndefined(){ if(Sheets.Item("Sheet1").Range("A1").Value2==undefined){ Sheets.Item("Sheet1").Range("A2").Value2="A1是空值" }else{ Sheets.Item("......
  • Git-简要教程
    和github连接安装git。之后所有命令全在gitbash中运行生成keyssh-keygen-ted25519-C"[email protected]"会生成一个私有key和public的key2.在你的用......
  • 腾讯云Ubuntu安装wordpress (1/3)
    主要用了下面的命令安装apachesudoaptinstallapache2-y安装mariadbsudoaptinstallmariadb-servermariadb-client-y取人mariadb是否安装成功sudosy......
  • 腾讯云Ubuntu安装wordpress (3/3)
    本篇主要是域名解析相关放到这里可能有点迟了,但买服务器的时候最好买香港,因为这样域名就不用备案了。同时买域名的时候需要实名,认证一个小时左右解析的方法,具体如下图......
  • 腾讯云Ubuntu安装wordpress (2/3)
    本篇主要是遇到的问题以及处理方法包含以下三个部分中文404问题markdown导入问题文件上传大小限制问题1.中文404问题这个很简单,直接在设置,固定链接里面选择朴素就......
  • Docker启动RabbitMQ访问15672连接超时解决方法
    docker成功启动rabbitmq后访问15672端口报连接超时原因:rabbitmq默认web界面管理插件是关闭的,需要通过命令开启解决办法:1、查看rabbit的容器id:dockerps2、进入......
  • Ubuntu 通过 docker 启动 mysql
    1、首先拉取MySQL的镜像dockerpullmysql2、运行mysql容器dockerrun--namemysql-p3306:7080-eMYSQL_ROOT_PASSWORD=88888888mysql--namemysql......