初始docker
docker 概念
docker 架构
docker 命令
docker 服务相关
镜像相关
镜像列表
[root@cindy ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
demo v1 dfd65eeddd33 3 weeks ago 661MB
zookeeper latest d696029db8fd 3 weeks ago 279MB
nginx latest 0e901e68141f 4 weeks ago 142MB
mysql latest 65b636d5542b 4 weeks ago 524MB
consul latest a0e0d99adce4 4 weeks ago 131MB
rancher/rancher latest f944ac578a0e 6 weeks ago 1.47GB
portainer/portainer-ce 2.11.0 0df02179156a 6 months ago 273MB
hello-world latest feb5d9fea6a5 9 months ago 13.3kB
lihaixin/portainer latest 4c51b4d5ebf2 14 months ago 79.1MB
bladex/sentinel-dashboard latest aa398704ebd3 22 months ago 147MB
ascdc/jdk8 latest 9f04bbc44406 4 years ago 644MB
查看镜像id
[root@cindy ~]# docker images -q
2cc3f16315b3
dfd65eeddd33
d696029db8fd
0e901e68141f
65b636d5542b
a0e0d99adce4
f944ac578a0e
0df02179156a
feb5d9fea6a5
4c51b4d5ebf2
aa398704ebd3
9f04bbc44406
镜像搜索
[root@cindy ~]# docker search redis
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
redis Redis is an open source key-value store that… 11070 [OK]
bitnami/redis Bitnami Redis Docker Image 224 [OK]
bitnami/redis-sentinel Bitnami Docker Image for Redis Sentinel 38 [OK]
bitnami/redis-cluster 33
rapidfort/redis RapidFort optimized, hardened image for Redi… 15
rapidfort/redis-cluster RapidFort optimized, hardened image for Redi… 15
circleci/redis CircleCI images for Redis 14 [OK]
ubuntu/redis Redis, an open source key-value store. Long-… 10
bitnami/redis-exporter 8
google/guestbook-python-redis A simple guestbook example written in Python… 5
clearlinux/redis Redis key-value data structure server with t… 4
ibmcom/redis-ha 1
bitnami/redis-sentinel-exporter 1
ibmcom/ibm-cloud-databases-redis-operator Container image for the IBM Operator for Red… 1
ibmcom/ibm-cloud-databases-redis-operator-bundle Bundle image for the IBM Operator for Redis 1
ibmcom/ibm-cloud-databases-redis-catalog Catalog image for the IBM Operator for Redis 1
ibmcom/redis-ppc64le 0
drud/redis redis 0 [OK]
blackflysolutions/redis Redis container for Drupal and CiviCRM 0
ibmcom/redisearch-ppc64le 0
greenbone/redis-server A redis service container image for the Gree… 0
rancher/redislabs-ssl 0
vmware/redis-photon 0
cimg/redis 0
newrelic/k8s-nri-redis New Relic Infrastructure Redis Integration (… 0
镜像Pull
docker pull xxx
docker 公有仓库: hub.docker.com/
删除镜像
docker rmi xxx
删除多个镜像
删除所有镜像
docker rmi docker images -q
容器相关
容器列表
[root@cindy ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
735348c8cc28 rancher/rancher "entrypoint.sh" 22 minutes ago Up 36 seconds 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:9001->80/tcp, :::9001->80/tcp clever_bohr
3d2acd671924 portainer/portainer-ce:2.11.0 "/portainer" 3 weeks ago Up 3 weeks 8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp portainer
[root@cindy ~]#
[root@cindy ~]#
[root@cindy ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
735348c8cc28 rancher/rancher "entrypoint.sh" 22 minutes ago Up Less than a second 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:9001->80/tcp, :::9001->80/tcp clever_bohr
f98d7d9223c7 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (143) 36 minutes ago zookeeper
a2c9e43bc7bc bladex/sentinel-dashboard:latest "java -Djava.securit…" 3 weeks ago Exited (143) 36 minutes ago sentinel
ee6d48da449b demo:v1 "/script/run.sh java…" 3 weeks ago Exited (0) 3 weeks ago sliceDemo
1435e600b3e6 mysql "docker-entrypoint.s…" 3 weeks ago Exited (0) 3 weeks ago mysql-test
0f7ece772f98 consul "docker-entrypoint.s…" 3 weeks ago Exited (1) 3 weeks ago consul1
5ab22b9cc10f nginx "/docker-entrypoint.…" 3 weeks ago Exited (0) 3 weeks ago nginx-test
3d2acd671924 portainer/portainer-ce:2.11.0 "/portainer" 3 weeks ago Up 3 weeks 8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp portainer
e78aadf039ca hello-world "/hello" 3 weeks ago Exited (0) 3 weeks ago elastic_snyder
[root@cindy ~]#
创建容器
-- 交互放入运行容器,并进入
docker run -it --name=容器1 redis:5.0 /bin/bash
-- 后台运行容器
docker run -id --name=容器1 redis:5.0 /bin/bash
进入容器
docker exec -it 容器1 /bin/bash
启动容器
docker start 容器名/id
停止容器
docker stop 容器名/id
删除容器
docker rm 容器id
// 删除镜像
docker rmi 镜像名
查看容器信息
docker inspect
容器数据卷
数据卷概念
配置数据卷
[root@cindy ~]# docker run -it --name=centos1 -v /root/data:/root/data_container centos:7 /bin/bash
Unable to find image 'centos:7' locally
7: Pulling from library/centos
2d473b07cdd5: Downloading [============================> ] 43.45MB/76.1MB
2d473b07cdd5: Pull complete
Digest: sha256:c73f515d06b0fa07bb18d8202035e739a494ce760aa73129f60f4bf2bd22b407
Status: Downloaded newer image for centos:7
docker 应用部署
mysql 部署
[root@cindy mysql]# docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=root -d mysql
59e130da6528920db1a06f4e96f729ef55b5302de4b6bee81b69a13e3b9d561f
[root@cindy mysql]#
[root@cindy mysql]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
59e130da6528 mysql "docker-entrypoint.s…" 11 seconds ago Up 10 seconds 3306/tcp, 33060/tcp some-mysql
3d2acd671924 portainer/portainer-ce:2.11.0 "/portainer" 3 weeks ago Up 3 weeks 8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp portainer
[root@cindy mysql]#
[root@cindy mysql]# docker exec -it some-mysql /bin/bash
root@59e130da6528:/#
root@59e130da6528:/#
root@59e130da6528:/# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29 MySQL Community Server - GPL
Copyright (c) 2000, 2022, 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>
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql>
tomcat 部署
nginx 部署
redis 部署
dockfile
dockerfile 镜像原理
镜像制作
dockerfile概念
centos的dockerfile