1. Install the required packages
sudo apt install apt-transport-https ca-certificates Software-properties-common Curl
2. Add GPG key, and add Docker-ce software source, here is the DOCKER-CE source of China University of Science and technology as an example
Curl-fssl HTTPS://MIRRORS.USTC.EDU.CN/DOCKER-CE/LINUX/UBUNTU/GPG | sudo apt-key add-
sudo add-apt-repository "Deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$ (LSB_RELEASE-CS) stable "
3. update package cache after adding success
sudo apt update
4. Installing Docker-ce
sudo apt install docker-ce
5. Set boot up and start Docker-ce (default is set and start after successful installation, can be ignored)
sudo systemctl enable Docker
sudo systemctl start Docker
6. Test Run
sudo Docker run Hello-world
7. Add current user to Docker user group, can run Docker without sudo (optional)
sudo groupadd Docker
sudo usermod-ag Docker $USER
Nginx
1. Pull the nginx image
sudo docker pull Nginx
2. Run the image
sudo docker run-d-P 80:80 nginx
Comments
-D means let the application runs in the Backgroup which would be a closed even you close the terminal
3. Access localhost check is it OK
4. Build a HTML of your own
sudo docker run-d-P 8088:80-v $PWD/httpfiles:/usr/share/nginx/html Nginx
Httpfiles is your file directory.
Visit localhost:8088 Check Again
Linux Common statements:
LS: List directory
Touch xxx.html New File
Cd.. Back to previous level
Docker Common statements:
1. Get the image
Docker pull
2. View the image information
Docker images
3. List containers
Docker PS
4. Stop
Docker stop
5. Start
Docker start
Ubuntu 18.04 Installing Docker and Nginx service settings