Deploy Docker Node.js in Redhat Linux
You can use your own dockerised Node.js in your Github repository or use the my repository for this Dockerize Node.js repository
This doc assumes that you already have a server running Redhat and that the ports are open to the internet for inbound and outbound.
Install Docker with Yum
- First you need to login to the host server with system
sudo
privileges - Enter
sudo su
to change to your privilege to a system user - Update your system yum package manager
yum update
- Enter
vi /etc/yum.repos.d/docker.repo
to open a vi editor - Paste the following lines to the file:
[dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg
- Install Docker by run:
yum install docker-engine -y
- Start Docker, run:
service docker start
- To check if your Docker process has started, run:
sudo docker run hello-world
Run your Node.Js project
- You can build your dockerised Node.js or use this demo repository.
- Run:
docker build https://github.com/ivanzcai/DockerizeNodeJsApp.git#master -t ivancai/dockerizenodejsapp:latest
- Check if the image has been created by enter:
docker images
you should see the repository ivancai/dockerizenodejsapp - Run the image on your docker container:
docker run -p 8081:8080 -d ivancai/dockerizenodejsapp
- Check if the demo application has been successfully deployed, goto your favourite browser, goto http://yourAddressOrPublicIp.com:8081 you should see hello World displayed.