im using AWS EC2 for VPS, Ubuntu 20.04 for operating system, and nginx as a web server.
First we need to install the docker
maybe you want to read more in their documentation
or using my method, step by step install docker
login as root
apt -y update
apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
'curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt -y update
apt -y install docker-ce docker-ce-cli containerd.io
and for checking the docker running
systemctl status docker
after the docker installation, choose your static website that you want to deploy.
after that, create a Dockerfile
nano Dockerfile
inside the Dockerfile
type this
# Choose the image
FROM nginx
# Remove the default file
RUN rm -rf /usr/share/nginx/html/*
# Copy and move your own website file to the nginx html folder
COPY ./{your directory website} /usr/share/nginx/html
its time to build your image
docker build -t {image name} .
for example
docker build -t theia .
and to check if your image build success
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
theia latest b8b7870c8621 24 minutes ago 143MB
nginx latest 0e901e68141f 11 days ago 142MB
if you see your docker image, now were gonna run it
docker run -d(for running in background) -p 8080:80(choose your not used port) --name(name your container) (your image)
for example
docker run -d -p 8080:80 --name thalia theia
and finally you can access your website using your public ip and port
example mine is 54.183.74.95:8080
if you have another method, feel free to discuss.
thanks for reading, have a nice day
Top comments (0)