login每天学习一点点,每天进步一点点.
当前位置:首页 >> Ubuntu/Centos安装docker

Ubuntu/Centos安装docker

2018-07-14 00:58:06  |  分类: Linux |  标签: 阅读(134)评论(0)

===========================CentOS==================================
替换系统源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

增加docker源

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum update


yum remove docker docker-common docker-selinux docker-engine

yum install -y yum-utils device-mapper-persistent-data lvm2


查看docker详细版本

yum list docker-ce --showduplicates | sort -r


安装docker

yum install docker-ce


运行程序并设置开机启动

systemctl start docker

systemctl enable docker


docker version


=====================================

卸载旧版软件包

yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

删除可能存在的旧版本

apt-get remove docker docker-engine docker-ce docker.io


===================================================================
============================Ubuntu==================================

安装环境

apt-get update

apt-get install -y apt-transport-https ca-certificates curl software-properties-common


添加Docker官方的GPG密钥

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -


写入软件源信息

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"


更新一下apt包索引

apt-get -y update


安装最新版本的Docker CE

apt-get -y install docker-ce


docker version


docker images


根据镜像创建容器

docker create -it mysql:5.7


启动容器

docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=root -d -i -p 3307:3306  mysql:5.7

docker run --name mysql02 -e MYSQL_ROOT_PASSWORD=root -d -i -p 3308:3306  mysql:5.7 /bin/sh -c "while true; do echo hello world; sleep 1; done"


列表容器

docker ps


进入MySQL终端

docker exec -it  c32922433b1a  /bin/bash


mysql -h 127.0.0.1 -u root -proot


use mysql;

update user set Host='%' where User = 'root';

flush privileges;


select User,Host,authentication_string from user;

删除容器

docker rm mysql03


停止容器运行

docker stop mysql03


上一篇:ubuntu使用nmap查询端口 下一篇:ThinkPHP5 的视图$view->fetch()和$view->display()的区别

猜你喜欢

发表评论:

0.172194s