Ubuntu 18.04 Installing Docker and Nginx service settings

Source: Internet
Author: User
Tags gpg docker ps docker run

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.