当前位置:网站首页>Deploy docker and install MySQL in centos7
Deploy docker and install MySQL in centos7
2022-06-23 05:48:00 【Zhun Xiaozhao】
centos7 Deploy docker
docker Installation and deployment
Create deployment user , give sudo jurisdiction
[r[email protected] ~]# useradd docker -d /home/docker
[[email protected] ~]# passwd docker
Change user docker Password .
new password :
Invalid password : The password is less than 8 Characters
Reenter the new password :
passwd: All authentication tokens have been successfully updated .
[[email protected] ~]# echo 'docker ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
[[email protected] ~]# su - docker
[[email protected] ~]$
One key deployment
[[email protected] ~]$ # Use the official installation script to automatically install
[[email protected] ~]$ curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
At home daocloud One click Install command :
curl -sSL https://get.daocloud.io/docker | sh
start-up
[[email protected] ~]$ sudo systemctl start docker
Check the status
[[email protected] ~]$ systemctl status docker
Set boot up
[[email protected] ~]$ # Set boot up
[[email protected] ~]$ sudo systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[[email protected] ~]$
Mirror operation
Look at the mirror image
[[email protected] ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Download mirroring ( Timeout error )
[[email protected] ~]$ docker pull hello-world
Using default tag: latest
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: TLS handshake timeout
Specifies that the image is pulled again
[[email protected] ~]$ sudo vi /etc/docker/daemon.json
[[email protected] ~]$ cat /etc/docker/daemon.json
{
"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
}
[[email protected] ~]$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
[[email protected] ~]$
[[email protected] ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 7 months ago 13.3kB
delete mirror
[[email protected] ~]$ docker rmi hello-world
Untagged: hello-world:latest
Untagged: [email protected]:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
Deleted: sha256:e07ee1baac5fae6a26f30cabfe54a36d3402f96afda318fe0a96cec4ca393359
[[email protected] ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[[email protected] ~]$
Container operation
#### Look at all the containers
[[email protected] ~]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Create a container
[[email protected] ~]$ docker create -it --name=test hello-world
aaa8f6652052d88c159e53ac9f88cbfa77934c8f7b31a615ec9f18acedb88f1e
[[email protected] ~]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aaa8f6652052 hello-world "/hello" 8 seconds ago Created test
Start the container
[[email protected] ~]$ docker start aaa8f6652052
aaa8f6652052
[[email protected] ~]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aaa8f6652052 hello-world "/hello" 29 seconds ago Exited (0) 3 seconds ago test
Check the log
[[email protected] ~]$ docker logs aaa8f6652052
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.
(amd64)
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 ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
Check container details
[[email protected] ~]$ docker inspect aaa8f6652052
[
{
"Id": "aaa8f6652052d88c159e53ac9f88cbfa77934c8f7b31a615ec9f18acedb88f1e",
"Created": "2022-05-07T06:56:57.904666417Z",
"Path": "/hello",
"Args": [],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 0,
"Error": "",
"StartedAt": "2022-05-07T06:57:22.999901707Z",
"FinishedAt": "2022-05-07T06:57:23.018206468Z"
},
"Image": "sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412",
"ResolvConfPath": "/var/lib/docker/containers/aaa8f6652052d88c159e53ac9f88cbfa77934c8f7b31a615ec9f18acedb88f1e/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/aaa8f6652052d88c159e53ac9f88cbfa77934c8f7b31a615ec9f18acedb88f1e/hostname",
"HostsPath": "/var/lib/docker/containers/aaa8f6652052d88c159e53ac9f88cbfa77934c8f7b31a615ec9f18acedb88f1e/hosts",
"LogPath": "/var/lib/docker/containers/aaa8f6652052d88c159e53ac9f88cbfa77934c8f7b31a615ec9f18acedb88f1e/aaa8f6652052d88c159e53ac9f88cbfa77934c8f7b31a615ec9f18acedb88f1e-json.log",
"Name": "/test",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "host",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/66c71552979e600283024720c28fce1bbffdba0baeb948675a02c5d6ee31cc9e-init/diff:/var/lib/docker/overlay2/176b33a38f9b52db5535389d92450c23bbd3f1beb06036d93b9853ea9550a3f1/diff",
"MergedDir": "/var/lib/docker/overlay2/66c71552979e600283024720c28fce1bbffdba0baeb948675a02c5d6ee31cc9e/merged",
"UpperDir": "/var/lib/docker/overlay2/66c71552979e600283024720c28fce1bbffdba0baeb948675a02c5d6ee31cc9e/diff",
"WorkDir": "/var/lib/docker/overlay2/66c71552979e600283024720c28fce1bbffdba0baeb948675a02c5d6ee31cc9e/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "aaa8f6652052",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/hello"
],
"Image": "hello-world",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "46ecfbf481103b2f5bc9d5cbae762c0eb427589483e905ed1d9216e530525d39",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/46ecfbf48110",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "c0c4813d6f77ca6c8b0b6c4faddd8a2041a3e1f93c56acd5fb22533b70e96444",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
]
[[email protected] ~]$
uninstall docker
docker-ce Community Edition ,docker-ee Enterprise Edition 
[[email protected] ~]$ sudo yum remove docker-ce -y
[[email protected] ~]$ sudo rm -rf /var/lib/docker
After unloading , You can also see the version number , Where is not unloaded clean ???
[[email protected] ~]$ docker -v
Docker version 20.10.15, build fd82621
[[email protected] ~]$
Uninstall old version command
[[email protected] ~]$ sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine -y
Loaded plug-in :fastestmirror
Parameters docker There is no match
Parameters docker-client There is no match
Parameters docker-client-latest There is no match
Parameters docker-common There is no match
Parameters docker-latest There is no match
Parameters docker-latest-logrotate There is no match
Parameters docker-logrotate There is no match
Parameters docker-engine There is no match
Don't delete any packages
[[email protected] ~]$
Manual deployment
Set up warehouse
Install dependency packages
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Set warehouse address , Select alicloud source address ( The official source address is slow )
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
install Docker Community Edition
sudo yum install -y docker-ce docker-ce-cli containerd.io
docker install MySQL
Pull MySQL Image file
[[email protected] ~]$ sudo docker pull mysql:8.0.25
8.0.25: Pulling from library/mysql
b4d181a07f80: Pull complete
a462b60610f5: Pull complete
578fafb77ab8: Pull complete
524046006037: Pull complete
d0cbe54c8855: Pull complete
aa18e05cc46d: Pull complete
32ca814c833f: Pull complete
9ecc8abdb7f5: Pull complete
ad042b682e0f: Pull complete
71d327c6bb78: Pull complete
165d1d10a3fa: Pull complete
2f40c47d0626: Pull complete
Digest: sha256:52b8406e4c32b8cf0557f1b74517e14c5393aff5cf0384eff62d9e81f4985d4b
Status: Downloaded newer image for mysql:8.0.25
docker.io/library/mysql:8.0.25
[[email protected] ~]$
Look at the mirror image
[[email protected] ~]$ sudo docker images
REPOSITORYTAG IMAGE ID CREATED SIZE
hello-world latestfeb5d9fea6a5 7 months ago13.3kB
mysql 8.0.255c62e459e087 10 months ago 556MB
[[email protected] ~]$
start-up MySQL Mirror image
docker run -itd --name test-mysql1 -p 3307:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
Parameter description :
- -p 3307:3306 : Mapping container service's 3306 Port to host 3307 port , The external host can directly pass through the host ip:3307 Access to the MySQL Service for
- MYSQL_ROOT_PASSWORD=123456: Set up MySQL service root User's password .
The machine was installed before mysql, Therefore, the port is changed to 3307, Otherwise conflict !
verification

边栏推荐
- 数字藏品市场才刚刚开始
- MySQL character set
- Oracle exception
- True MySQL interview question (XXII) -- condition screening and grouping screening after table connection
- Heimdall database proxy scale out 20 times
- Mobile phone wireless charging dual coil 15W scheme SOC IC ip6809
- MySQL面试真题(二十九)——案例-找到爱看的电影
- MySQL面试真题(二十五)——常见的分组比较场景
- PAT 乙等 1012 C语言
- MySQL Foundation
猜你喜欢

How does win11 enable mobile hotspot? How to enable mobile hotspot in win11

Pkav simple blasting

C prime plus notes d'apprentissage - 2, constantes et formatage io (I / o)

Wechat applet: Star Trek spaceship ticket production and generation
![[OWT] OWT client native P2P E2E test vs2017 build 6: modify script automatic generation vs Project](/img/ce/2e0b0c0f6fae24b5b0df2680229284.png)
[OWT] OWT client native P2P E2E test vs2017 build 6: modify script automatic generation vs Project

Alibaba cloud object storage oss+picgo+typera implements the construction map

Wechat applet: elderly blessing short video

数字藏品市场才刚刚开始

雷达图canvas

Use of visdom
随机推荐
[opencv450] inter frame difference method
Wechat applet: future wife query generator
PAT 乙等 1012 C语言
数字藏品赋能实体产业释放了哪些利好?
android Handler内存泄露 kotlin内存泄露处理
True question of MySQL interview (29) -- case - finding favorite movies
Differences between fs4059a and fs5080e charging chips
Yingjixin launched 4 series of lithium batteries 100W mobile power supply voltage rise and fall scheme SOC chip ip5389
[graduation season u; advanced technology Er] farewell to the confused self in the past two years. Regroup, junior I'm coming
node中操作mongoDB
jvm: 方法重载时,具体调用哪个方法,是由传入参数的静态类型来决定的,而不是由参数的实际类型来决定
英集芯ip6806无线充电方案5W过Qi认证外围精简14颗器件
Genetic engineering of AI art? Use # artbreeder to change any shape of the image
线性表 链表结构的实现
Heimdall database proxy scale out 20 times
MySQL面试真题(二十七)——RFM分析法对用户进行分类
数字藏品——新的投资机遇
Redis cache penetration solution - bloom filter
MySQL面试真题(二十五)——常见的分组比较场景
PAT 乙等 1023 组个最小数
