docker之映象下載
阿新 • • 發佈:2022-01-02
1、映象搜尋
[root@localhost ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 16057 [OK] jwilder/nginx-proxy Automated Nginx reverse proxy fordocker con… 2105 [OK] richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 819 [OK] jc21/nginx-proxy-manager Docker container for managing Nginx proxy ho… 303 linuxserver/nginx An Nginx container, brought to you by LinuxS… 161jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 148 [OK] tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rtmp… 148 [OK] alfg/nginx-rtmp NGINX, nginx-rtmp-module and FFmpeg from sou… 112[OK] nginxdemos/hello NGINX webserver that serves a simple page co… 81 [OK] privatebin/nginx-fpm-alpine PrivateBin running on an Nginx, php-fpm & Al… 61 [OK] docker映象名字 描述 受歡迎程度 是否官方提供
2、映象下載
方法1:從docker hub 拉取
[root@localhost ~]# docker pull nginx Using default tag: latest latest: Pulling from library/nginx a2abf6c4d29d: Pull complete a9edb18cadd1: Pull complete 589b7251471a: Pull complete 186b1aaa4aa6: Pull complete b4df32aa5a72: Pull complete a0bcbecc962e: Pull complete Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31 Status: Downloaded newer image for nginx:latest docker.io/library/nginx:latest
方法2:使用阿里雲加速器
https://cr.console.aliyun.com(需要註冊)
配置加速器
[root@localhost ~]# mkdir -p /etc/docker #
[root@localhost ~]# tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["加速地址"]
}
EOF
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
檢視配置情況(紅色部分為你的加速地址)
[root@localhost ~]# docker info... Registry Mirrors: https://xxxxxx.mirror.aliyuncs.com/ Live Restore Enabled: false
方法3:image映象匯入
[root@localhost ~]# docker load -i /root/docker-nginx.tar
方法4:直接下載其他站點的映象
[root@localhost ~]# docker pull hub.c.163.com/library/nginx:latest latest: Pulling from library/nginx 5de4b4d551f8: Pull complete d4b36a5e9443: Pull complete 0af1f0713557: Pull complete Digest: sha256:f84932f738583e0169f94af9b2d5201be2dbacc1578de73b09a6dfaaa07801d6 Status: Downloaded newer image for hub.c.163.com/library/nginx:latest hub.c.163.com/library/nginx:latest
3、檢視 images 列表
[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 605c77e624dd 3 days ago 141M
docker ps // 檢視所有正在執行容器 docker stop containerId // containerId 是容器的ID docker ps -a // 檢視所有容器 docker ps -a -q // 檢視所有容器ID docker stop $(docker ps -a -q) // stop停止所有容器 docker rm $(docker ps -a -q) // remove刪除所有容器
4、開啟動網路轉發功能
[root@localhost ~]# vim /etc/sysctl.conf #插入以下內容 net.ipv4.ip_forward = 1[root@localhost ~]# sysctl -p #生效 net.ipv4.ip_forward = 1[root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward 1 否則,docker啟動例項時,會報錯以下警告:
[root@localhost ~]# systemctl stop firewalld && systemctl disable firewalld #關閉防火牆
5、啟動實列nginx
[root@localhost ~]# docker run --name nginx -p 80:80 -d nginx f47856b2612acd70f938b373d0f37b956232018b691d302b18ef982014a60918
需要手動建立daemon.json檔案