- 尚硅谷大数据技术-教程-学习路线-笔记汇总表【课程资料下载】
- 视频地址:尚硅谷Docker实战教程(docker教程天花板)_哔哩哔哩_bilibili
- 尚硅谷Docker实战教程-笔记01【理念简介、官网介绍、平台入门图解、平台架构图解】
- 尚硅谷Docker实战教程-笔记02【安装docker、镜像加速器配置】
- 尚硅谷Docker实战教程-笔记03【Docker常用命令】
- 尚硅谷Docker实战教程-笔记04【Docker镜像】
尚硅谷Docker实战教程-笔记05【本地镜像发布到阿里云与私有库】
尚硅谷Docker实战教程-笔记06【Docker容器数据卷】
尚硅谷Docker实战教程-笔记07【Docker常规安装简介】
目录
1.基础篇
8.Docker常规安装简介
P034【34_docker上安装常用软件说明】04:37
P035【35_tomcat安装上集】04:42
P036【36_tomcat安装下集】06:58
P037【37_mysql安装上集】13:48
P038【38_mysql安装下集】11:34
P039【39_redis常规安装】14:45
1.基础篇
8.Docker常规安装简介
P034【34_docker上安装常用软件说明】04:37
总体步骤:
- 搜索镜像
- 拉取镜像
- 查看镜像
- 启动镜像——服务端口映射
- 停止容器
- 移除容器
P035【35_tomcat安装上集】04:42
docker:https://hub.docker.com/
docker pull tomcat
[root@node001 ~]# docker images
[root@node001 ~]# docker search tomcat
[root@node001 ~]# docker pull tomcat
[root@node001 ~]# docker images
[root@node001 ~]# docker run -d -p 8080:8080 --name t1 tomcat
216c7467a79968fa06dca9fd59dad9b4ec28eb6312c7dab847a3b9e8aa4d603a
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
216c7467a799 tomcat "catalina.sh run" 18 seconds ago Up 17 seconds 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp t1
[root@node001 ~]#
P036【36_tomcat安装下集】06:58
[root@node001 ~]# docker run -d -p 8080:8080 --name t1 tomcat
216c7467a79968fa06dca9fd59dad9b4ec28eb6312c7dab847a3b9e8aa4d603a
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
216c7467a799 tomcat "catalina.sh run" 18 seconds ago Up 17 seconds 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp t1
[root@node001 ~]# docker exec -it 216c7467a799 /bin/bash
root@216c7467a799:/usr/local/tomcat# pwd
/usr/local/tomcat
root@216c7467a799:/usr/local/tomcat# ls -l
total 160
-rw-r--r-- 1 root root 18994 Dec 2 2021 BUILDING.txt
-rw-r--r-- 1 root root 6210 Dec 2 2021 CONTRIBUTING.md
-rw-r--r-- 1 root root 60269 Dec 2 2021 LICENSE
-rw-r--r-- 1 root root 2333 Dec 2 2021 NOTICE
-rw-r--r-- 1 root root 3378 Dec 2 2021 README.md
-rw-r--r-- 1 root root 6905 Dec 2 2021 RELEASE-NOTES
-rw-r--r-- 1 root root 16517 Dec 2 2021 RUNNING.txt
drwxr-xr-x 2 root root 4096 Dec 22 2021 bin
drwxr-xr-x 1 root root 4096 Jul 3 07:50 conf
drwxr-xr-x 2 root root 4096 Dec 22 2021 lib
drwxrwxrwx 1 root root 4096 Jul 3 07:50 logs
drwxr-xr-x 2 root root 4096 Dec 22 2021 native-jni-lib
drwxrwxrwx 2 root root 4096 Dec 22 2021 temp
drwxr-xr-x 2 root root 4096 Dec 22 2021 webapps
drwxr-xr-x 7 root root 4096 Dec 2 2021 webapps.dist
drwxrwxrwx 2 root root 4096 Dec 2 2021 work
root@216c7467a799:/usr/local/tomcat# cd webapps
root@216c7467a799:/usr/local/tomcat/webapps# ls -l
total 0
root@216c7467a799:/usr/local/tomcat/webapps# cd ..
root@216c7467a799:/usr/local/tomcat# rm -r webapps
root@216c7467a799:/usr/local/tomcat# ls -l
total 156
-rw-r--r-- 1 root root 18994 Dec 2 2021 BUILDING.txt
-rw-r--r-- 1 root root 6210 Dec 2 2021 CONTRIBUTING.md
-rw-r--r-- 1 root root 60269 Dec 2 2021 LICENSE
-rw-r--r-- 1 root root 2333 Dec 2 2021 NOTICE
-rw-r--r-- 1 root root 3378 Dec 2 2021 README.md
-rw-r--r-- 1 root root 6905 Dec 2 2021 RELEASE-NOTES
-rw-r--r-- 1 root root 16517 Dec 2 2021 RUNNING.txt
drwxr-xr-x 2 root root 4096 Dec 22 2021 bin
drwxr-xr-x 1 root root 4096 Jul 3 07:50 conf
drwxr-xr-x 2 root root 4096 Dec 22 2021 lib
drwxrwxrwx 1 root root 4096 Jul 3 07:50 logs
drwxr-xr-x 2 root root 4096 Dec 22 2021 native-jni-lib
drwxrwxrwx 2 root root 4096 Dec 22 2021 temp
drwxr-xr-x 7 root root 4096 Dec 2 2021 webapps.dist
drwxrwxrwx 2 root root 4096 Dec 2 2021 work
root@216c7467a799:/usr/local/tomcat# mv webapps.dist webapps
root@216c7467a799:/usr/local/tomcat# ls -l
total 156
-rw-r--r-- 1 root root 18994 Dec 2 2021 BUILDING.txt
-rw-r--r-- 1 root root 6210 Dec 2 2021 CONTRIBUTING.md
-rw-r--r-- 1 root root 60269 Dec 2 2021 LICENSE
-rw-r--r-- 1 root root 2333 Dec 2 2021 NOTICE
-rw-r--r-- 1 root root 3378 Dec 2 2021 README.md
-rw-r--r-- 1 root root 6905 Dec 2 2021 RELEASE-NOTES
-rw-r--r-- 1 root root 16517 Dec 2 2021 RUNNING.txt
drwxr-xr-x 2 root root 4096 Dec 22 2021 bin
drwxr-xr-x 1 root root 4096 Jul 3 07:50 conf
drwxr-xr-x 2 root root 4096 Dec 22 2021 lib
drwxrwxrwx 1 root root 4096 Jul 3 07:50 logs
drwxr-xr-x 2 root root 4096 Dec 22 2021 native-jni-lib
drwxrwxrwx 2 root root 4096 Dec 22 2021 temp
drwxr-xr-x 7 root root 4096 Dec 2 2021 webapps
drwxrwxrwx 2 root root 4096 Dec 2 2021 work
root@216c7467a799:/usr/local/tomcat# exit
exit
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
216c7467a799 tomcat "catalina.sh run" 10 minutes ago Up 10 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp t1
[root@node001 ~]# docker stop t1
t1
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@node001 ~]# docker rm -f t1
t1
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@node001 ~]#
- docker pull billygoo/tomcat8-jdk8
- docker run -d -p 8080:8080 --name mytomcat8 billygoo/tomcat8-jdk8
[root@node001 ~]# docker run -d -p 8080:8080 --name mytomcat8 billygoo/tomcat8-jdk8
Unable to find image 'billygoo/tomcat8-jdk8:latest' locally
latest: Pulling from billygoo/tomcat8-jdk8
55cbf04beb70: Pull complete
1607093a898c: Pull complete
9a8ea045c926: Pull complete
1290813abd9d: Pull complete
8a6b982ad6d7: Pull complete
abb029e68402: Pull complete
8cd067dc06dc: Pull complete
1b9ce2097b98: Pull complete
d6db5874b692: Pull complete
25b4aa3d52c5: Pull complete
d26b86f009c9: Pull complete
e54998e5e699: Pull complete
4a1e415a3c2e: Pull complete
Digest: sha256:4e21f52d29e3a0baafc18979da2f9725449b54652db69d4cdaef9ba807097e11
Status: Downloaded newer image for billygoo/tomcat8-jdk8:latest
000fab49fa217f9d651bd9d17a99bd9ce7e3461abaa2b9cc1c7884c653f6d8c8
[root@node001 ~]#
P037【37_mysql安装上集】13:48
docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
[root@node001 ~]# docker run -p 3307:3307 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
220798db32afe49a5b4509b447124252eaf54f2be4e627ef4e11507959056284
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
220798db32af mysql:5.7 "docker-entrypoint.s…" 10 seconds ago Up 7 seconds 3306/tcp, 33060/tcp, 0.0.0.0:3307->3307/tcp, :::3307->3307/tcp elastic_turing
000fab49fa21 billygoo/tomcat8-jdk8 "catalina.sh run" 43 minutes ago Up 43 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp mytomcat8
[root@node001 ~]# docker exec -it 220798db32af /bin/bash
root@220798db32af:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> create databases db01;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'databases db01' at line 1
mysql> create database db01;
Query OK, 1 row affected (0.00 sec)
mysql> use db01;
Database changed
mysql> create table t1(id int, name varchar(20));
Query OK, 0 rows affected (0.02 sec)
mysql> insert into t1 values(1, 'zs');
Query OK, 1 row affected (0.10 sec)
mysql> select * from t1;
+------+------+
| id | name |
+------+------+
| 1 | zs |
+------+------+
1 row in set (0.01 sec)
mysql> grant all privileges on *.* to root@"%" identified by"root" with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
mysql> select Host,User from user;
+-----------+---------------+
| Host | User |
+-----------+---------------+
| % | root |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
4 rows in set (0.00 sec)
mysql> update user set host = '%' where user ='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql>
P038【38_mysql安装下集】11:34
docker run -d -p 3306:3306 --privileged=true -v /zzyyuse/mysql/log:/var/log/mysql -v /zzyyuse/mysql/data:/var/mysql -v /zzyyuse/mysql/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=123456 --name mysql mysql:5.7
docker run -d -p 3306:3306 --privileged=true
-v /zzyyuse/mysql/log:/var/log/mysql
-v /zzyyuse/mysql/data:/var/mysql
-v /zzyyuse/mysql/conf:/etc/mysql/conf.d
-e MYSQL_ROOT_PASSWORD=123456
--name mysql
mysql:5.7
docker run -d -p 3307:3307 --privileged=true
-v /opt/docker/mysql/log:/var/log/mysql
-v /opt/docker/mysql/data:/var/mysql
-v /opt/docker/mysql/conf:/etc/mysql/conf.d
-e MYSQL_ROOT_PASSWORD=123456
--name mysql
mysql:5.7
docker run -d -p 3307:3307 --privileged=true -v /opt/docker/mysql/log:/var/log/mysql -v /opt/docker/mysql/data:/var/mysql -v /opt/docker/mysql/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=123456 --name mysql mysql:5.7
P039【39_redis常规安装】14:45
[root@node001 mysql]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@node001 mysql]# docker run -d -p 6379:6379 redis:6.0.8
b07956757ed1794d6909a4fdaa24d3a563b1be5ff2a2266cb6c44e1620d5d4b9
[root@node001 mysql]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b07956757ed1 redis:6.0.8 "docker-entrypoint.s…" 19 seconds ago Up 17 seconds 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp wizardly_borg
[root@node001 mysql]# docker exec -it b07956757ed1 /bin/bash
root@b07956757ed1:/data# redis-cli
127.0.0.1:6379> set k1 v1
OK
127.0.0.1:6379> get k1
"v1"
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
root@b07956757ed1:/data# exit
exit
[root@node001 mysql]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b07956757ed1 redis:6.0.8 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp wizardly_borg
[root@node001 mysql]# docker rm -f b07956757ed1
b07956757ed1
[root@node001 mysql]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@node001 mysql]#