Getting started with Docker on Oracle Cloud Infrastructure


This blog summarizes the commonly used commands while running Docker on OCI.

The assumption is that you are using Oracle Linux 7 image on your cloud compute instance.

To get started, first update the yum settings:

cd /etc/yum.repos.d/

sudo su


Now install Docker:

#yum install docker-engine

systemctl start docker

systemctl enable docker

systemctl status docker

Check if Docker installed successfully:

docker run hello-world

List docker images

docker images

List docker containers:

sudo docker ps

docker ps -a

Pull a docker image from Docker hub repository

docker pull labanish/mynginx2

Run container on detached mode

docker run --name mynginxLabanish -p 81:80 -d labanish/mynginx2

Run a docker container interactively

docker run -it alpine /bin/sh

Execute /open & edit a container

docker exec -it <static-site> bash

To edit files inside a Docker container – you need to install vim:

Install vim:

apt-get update
apt-get install vim

To create a new image out of a container.

docker commit <container_name> <new image name>

Example: Create new image from a container called static-site

docker commit static-site labanish/static-site

Push to docker hub

docker push labanish/static-site

An example command to run container “Static-site”. Mapping port 80 to port 3003. It runs in detached mode, with name “StaticfromLaban”

docker run -d --restart unless-stopped --name=StaticfromLaban -p=3003:80 labanish/static-site

Check the port on a container

# docker port StaticfromLaban
80/tcp ->

view docker logs:

 docker logs --follow orcl 

Security & Networking:

Make sure your ports are accessible from the internet by adding them on the ingress rules in the security list of your VCN.

Also remember using the firewall command.

sudo firewall-cmd --zone=public --add-port=3003/tcp --permanent

sudo firewall-cmd --reload

Known Issues:

How to fix docker: Got permission denied while trying to connect to the Docker daemon socket (when you run docker cmds without sudo)
  • Create a docker group
sudo groupadd docker
  • Add your user to the docker group
sudo usermod -aG docker ${USER}
  • Log out and login again to effect the changes
su -s ${USER}

Test by running docker commands without sudo!


Docker Samples

Sample Voting app

Installing Docker on Oracle Linux

0 0 vote
Article Rating

I am a Cloud Solutions Engineer working with a leading cloud solutions company. I have more than 5 years’ experience in the Tech ecosystem. I began my career as a software developer. I am a tech enthusiast, an autodidact whose interests includes Data Management, Cloud Native Development, Mobile and Bots Development, Integration, Low Code Development, AI, Analytics just to say the least.

Notify of
Inline Feedbacks
View all comments