Docker的基本命令
启动docker
$sudo systemctl start docker
获取镜像
$docker pull [image]
$docker pull ubuntu
启动容器
docker run
查看所有的容器
$ docker ps
查看所有的镜像
$ docker images
删除所有的镜像
docker rmi $(docker images -q)
删除所有的容器
docker rm $(docker ps -aq)
Docker Compose
查看容器运行状态
列出所有的容器及其运行状态
$ docker-compose ps
[root@happy test]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------
container_mysql docker-entrypoint.sh --cha ... Up 0.0.0.0:3306->3306/tcp,:::3306->3306/tcp, 33060/tcp
container_redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp,:::6379->6379/tcp
nginx /docker-entrypoint.sh ngin ... Up 0.0.0.0:80->80/tcp,:::80->80/tcp
web java -jar /app.jar --serve ... Up 0.0.0.0:8080->8080/tcp,:::8080->8080/tcp
[root@happy test]#
启动
$ docker-compose up -d 后台启动
$ docker-compose up --build build 并启动
停止
$ docker-compose down
查看容器的信息
[root@happy test]# docker inspect nginx
"IPAddress": "172.26.0.4",
查看liunx 本机IP
$ ifconfig
删除所有容器
docker rm $(docker ps -aq)
删除所有的镜像
docker rmi $(docker images -q)
Nginx
Nginx 配置
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
location / {
proxy_pass http://balance;
}
}
upstream balance{
server 172.17.0.1:8080; #docker的IP地址
}
include /etc/nginx/conf.d/*.conf;
}
查看docker的IP
[root@happy test]# ip addr show docker0
3: docker0: mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:7c:ab:6d:00 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:7cff:feab:6d00/64 scope link
valid_lft forever preferred_lft forever
Docker 教程
https://docker.easydoc.net/doc/81170005/cCewZWoN/lTKfePfP
k8s -https://k8s.easydoc.net/docs/dRiQjyTY/28366845/6GiNOzyZ/9EX8Cp45