Deploy Docker Container for Free on Oracle Cloud

Özgür Peynirci
5 min readAug 30, 2024

--

Many times we have small apps that we want to show to some people without hassle of explaining steps on how to configure and run our apps on their own machine, or run the fear of getting a Free(!) tier cloud product that could quickly exceed that Free™ tier at a moments notice.

Fortunately Oracle offers Always Free option where you don’t deal with unnecessary risks just to deploy a small app.

1. Create an Oracle Cloud account

Oracle will try to verify ownership of payment method you provided, although it won’t charge you for using always free products you will use here.

Use Chrome/Safari/Firefox/Edge for this tutorial asother browsers aren’t allowed to main screen.

2. Launch Virtual Machine

You will notice we have 250£ free credits, but really, it’s impossible to consume this if you don’t go a fancy route. Also, it won’t charge you once your credit is depleted. (If you can!)

Click on top left corner in the main screen of cloud.oracle.com and go Compute > Instances.

Click on Create Instance button.

Click Edit button, as we want to change operating system to another always free option, Ubuntu.

Click Change Image.

Choose Ubuntu.

Choose a build. It doesn’t matter that much.

Finally, click Select Image.

Scroll down and you’ll see Add SSH keys section, which you have to download private key by clicking Save private key here.

Finally, click Create at the bottom left corner of the screen.

3. Ingres Rules Settings to make ports accessible to outside

Now that we have our VM, click on that VM and find Instance details page. You will see your public IP address here. You will also see Virtual Cloud Network: xxx part. Click on that link.

Click on subnet link on the following page.

Click on the security list link on the following page.

Click on Add Ingress Rules, write the Source CIDR as 0.0.0.0/0

You may want to specify which ports are allowed for public access, in the Destination Port Range field. Otherwise you can leave this empty and click Add Ingress Rules at the bottom.

4. Create SSH Keys to connect to Virtual Machine

We use SSH keys to connect to cloud servers rather than passwords. It’s more secure. Download PuTTY. Run PuTTYgen (access it through search bar or Start Menu) which should have come included in PuTTY installation.

Run PuTTYgen

Click Load

Change this part to be All Files (*.*)

Choose the .key file we downloaded when we created the instance. Enter the key passphrase of your choice (this will be your password essentially) and click on Save private key on PuTTYgen. It will create a file with extension *.ppk.

5. Transfer your app files to Virtual Machine

On Windows, you need WinSCP. On macOS you may choose FileZilla. On Linux, you probably know what you’re doing!

I’ll go with WinSCP here.

Enter public IP Address of virtual machine as host name here. That IP Address is in Instance Details page in Oracle Cloud. User name should be ubuntu. Now, don’t click Login yet, click on Advanced… instead.

Choose Authentication section on the left under SSH, click on button and choose the *.ppk file we created before.

Choose .ppk, not .key file

Hit OK and click on Login now.

Left part is your comptuer, right part is server. You can just drag and drop any file you want. You can’t send them to the root path though, send time somewhere like /home/ubuntu.

NOTE: Sending folders take too much time, so either compress your folders (like zip) or send non-folder files.

6. Enter the virtual machine and install docker compose

Run PuTTY we installed earlier.

Enter the host name same as we did in WinSCP.

Click on Credentials section on left and click first Browse… button to use the same *.ppk file we used for WinSCP.

7. Build and run the container

Now that your username asked (ubuntu by default) and passphrase asked (whatever you entered on PuTTYgen while you created *.ppk file) and you authenticated correctly, you should be in system.

Use cd command to be where the folder you uploaded using WinSCP is. If you uploaded a zip file, enter the command sudo apt-get install unzip and enter unzip filename.zip.

Now, enter that folder where our docker-compose.yml file is.

First we have to install docker and docker compose to run that file.

Copy and paste commands from 1st and 2nd steps you see here: https://docs.docker.com/engine/install/ubuntu/

For docker compose:

sudo apt-get install docker-compose-plugin

Now we can finally run our docker-compose.yml file.

sudo docker-compose build

sudo docker-compose up

8. See if public IP address if working!

Enter the public IP address of our instance along with the port our application uses. I configured my React app to use port 80 instead of 3000.

http://158.180.229.76:80/

That’s it!

--

--