Docker Part Three: Deploy a Container to the Web
We've built an image, provisioned a server, and set up Nginx with SSL. Time to actually get something running.
Step 1: SSH into your machine
Step 2: Run your container
Pull and run whatever image you like. I'm using the Express app from Part One:
docker run -p 3000:3000 -d vohzd/expressStep 3: Configure Nginx to proxy to it
Open your site config:
nano /etc/nginx/sites-available/example.comAdd a proxy_pass block to route traffic to your Docker container:
location / {
try_files $uri $uri/ =404;
}
location /docker {
proxy_pass http://localhost:3000/;
}Step 4: Restart Nginx
systemctl restart nginxVisit example.com/docker and you should see your app running. That's the entire Docker trilogy: build an image, set up a server, deploy the container.
Congratulations, you're now dangerously close to being a DevOps engineer. Don't let it go to your head.
Previous: Provision a VPS with Nginx and SSL
