Raspberry PI installedDocker
Docker is an open source application container engine, which is based on Go language and complies with Apache2.0 protocol. It allows developers to package their applications and dependencies into a lightweight, portable container that can be published on any popular Linux machine. Virtualization is also possible. The containers are completely sandboked, there is no interface to each other, and more importantly, the performance overhead of the containers is extremely low.
Install the docker
-
Install using the installation script
$ curl -sSL https://get.docker.com | sh Copy the code
-
Manual installation
-
Dependencies required to install Docker
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common Copy the code
-
Add the docker source
$ curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo apt-key add - $ echo "deb [arch=armhf] https://download.docker.com/linux/raspbian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list Copy the code
-
Update the source
$ sudo apt update Copy the code
-
Install the docker
$ sudo apt install docker-ce Copy the code
-
Check whether the installation is successful
$ sudo docker --version Copy the code
-
Set the docker domestic image
$ sudo nano /etc/docker/daemon.json Copy the code
Add the following
{ "registry-mirrors": ["https://registry.docker-cn.com"]}Copy the code
-
Restart the docker
$ sudo systemctl restart docker.service Copy the code
-
Powered up
$ sudo systemctl enable docker.service Copy the code
-
Install the Docker Visual Management tool (portainer
)
-
Pull the mirror
$ sudo docker pull portainer/portainer-ce Copy the code
-
Start the portainer
$ sudo docker volume create portainer_data $ sudo docker run -d -p 9000:9000 --name portainer \ --restart always -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data portainer/portainer-ce Copy the code
Enable port 9000 sudo Ufw Allow 9000
Install nginx
-
Pull the Nginx image
$ sudo docker pull nginx Copy the code
-
Set the nginx directory
$ mkdir ~/workspace # Create a working directory (not required) $ cd workspace/ $ mkdir nginx # create nginx directory $ mkdir nginx/log Create nginx log directory $ mkdir nginx/conf Create nginx base configuration file directory $ nano nginx/conf/nginx.conf Create the base configuration file $ mkdir nginx/conf.d # Create nginx virtual host configuration directory $ nano nginx/conf.d/default.conf Create default nginx virtual host configuration file $ mkdir nginx/html # Create static resource directory $ nano nginx/html/index.html Create default entry page Copy the code
-
nginx.conf
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } Copy the code
-
defalut.conf
server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; autoindex on; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root/usr/share/nginx/html; }}Copy the code
-
index.html
<! DOCTYPEhtml> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> </body> </html> Copy the code
-
-
Start the Nginx service
$ sudo docker run --name web_nginx_server -d -p 80:80 -p 8080:8080 \ -v /home/pi/workspace/nginx/log:/var/log/nginx \ -v /home/pi/workspace/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \ -v /home/pi/workspace/nginx/conf.d:/etc/nginx/conf.d \ -v /home/pi/workspace/nginx/html:/usr/share/nginx/html nginx Copy the code