In this tutorial, you will be installing and setting up Node.js on an Alibaba Cloud Elastic Compute Service (ECS) instance with Ubuntu 16.04.
Before proceeding with installation of any kind of package, run the following command to update your Ubuntu system. To run this command, remember to login from non-root user with sudo privileges.
# sudo apt update && sudo apt upgrade
Software-properties-common package is required to get the supported files for installation of Docker CE. In order to install software-properties-common package, follow the steps below.
To install software-properties-common, run the following command.
# sudo apt-get install software-properties-common -y
Apt-transport-https is required for installation of Docker CE. In order to install apt-transport-https, complete the steps below.
To install apt-transport-https, run the command below.
# sudo apt-get install apt-transport-https -y
Ca-certificates is required for installation of Docker CE. In order to install ca-certificates, follow the steps below.
To install ca-certificates, run the command.
# sudo apt-get install ca-certificates -y
Curl is required for installation of Docker CE. In order to install curl, follow the steps below.
To install curl, run the command.
# sudo apt-get install curl -y
To install Docker community edition, complete the steps below:
Add GPG key for Docker by running the command below.
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Run the following command to verify the fingerprint of GPG key.
# sudo apt-key fingerprint 0EBFCD88
Now add the Docker repository by running the command below.
# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update your system by running the command below to load added repository.
# sudo apt update
Run the following command to install Docker.
# sudo apt install docker-ce
Add your username to docker group by running the command below.
# sudo adduser aareez docker
Close your current shell session and start a new session because, otherwise, you won't be able to run docker and you may see permission errors.
Next, run the following command to check either docker run correctly or not.
# docker run hello-world
To download and install Docker compose, follow the steps below.
Run the following command to download and install latest version of docker compose.
# sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
Set the permissions for file by running the command below.
# sudo chmod +x /usr/local/bin/docker-compose
Get list of started containers by running the following command.
# docker container ls --all
Stop container using port 8080. To do so, get container id, replace it with 8baab990c424 below and run the command below.
# docker stop 8baab990c424
In this tutorial specifically, I will use official image of Node.js for installation on Docker. To download and install Node.js, you will need to run the following command which will pull latest Nodejs from official docker repository.
# docker pull linode/server-node-js
Now run the following command to run docker image.
# docker run -d -p 80:3000 linode/server-node-js
Now you can verify it by accessing your Alibaba Cloud ECS IP address or domain name pointing to that IP address.
You will see the following page.
If you have activated firewalls, you will have to define a rule in Alibaba Cloud security group for your cloud server to add exception for port 80/tcp and 443/tcp. You can enable these ports while creating ECS instance, but in case if you forgot to unblock these ports, you can follow the procedure in this guide: Add security group rules
Alibaba Clouder - November 27, 2019
Alibaba Clouder - October 28, 2019
Alibaba Clouder - March 6, 2019
Alibaba Clouder - March 29, 2019
Alibaba Clouder - May 5, 2019
Alibaba Clouder - May 6, 2019
An online computing service that offers elastic and secure virtual cloud servers to cater all your cloud hosting needs.Learn More
An on-demand database hosting service for MySQL, SQL Server and PostgreSQL with automated monitoring, backup and disaster recovery capabilitiesLearn More
An encrypted and secure cloud storage service which stores, processes and accesses massive amounts of data from anywhere in the worldLearn More
More Posts by Alibaba Clouder