Docker on Oracle Cloud





Register to Oracle Cloud and deploy:

  • Amper based Instance with Oracle Centos 8 OS
  • Generate and copy your public key
  • After VM is ready, connect using ssh and key

Update VM and install Docker

sudo yum update -y
sudo yum upgrade -y
sudo dnf install -y dnf-utils zip unzip
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install -y docker-ce --nobest
sudo systemctl enable docker
sudo systemctl start docker
systemctl status docker

Install docker-compose

sudo yum install -y libffi libffi-devel openssl-devel  python3-devel
sudo pip3 install docker-compose
docker-compose version

Add user to docker group

sudo usermod -aG docker ${USER}     # add user to group  
su - ${USER}                        # relogin to user
sudo -i && passwd <username>        # reset password if needs


Run Apache container

1) Make a folder for container and create html page there
mkdir web-container
cd web-container
echo "working!" > index.html

2) Run container (run in background, to port 8080 with mapped volume)
sudo docker run -dit --name my-apache-app -p 8080:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4

Open Ports OS level (firealld)

sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
netstat -tunap | grep 8080

Open Ports Oracle Level (ingress rule of network)

1) Go to list of instances and open needed one from list
https://cloud.oracle.com/compute/instances

2) Instance information --> Primary VNIC --> click on 'subnet' link

3) Resources --> Security Lists --> click on required name 

4) Resources --> Ingress Rules --> add Ingress Rule


Check port is open

from server itself:
curl:    curl localhost:8080        # check container is running on port 8080

from outside of server:
cmd:    telnet x.x.x.x 8080        # from windows comandline
web:    http://x.x.x.x:8080         # from outside browser


Fixing issues

If you get "permission denied":
1) sudo docker exec -it <container_name/id> bash
2)  cat config/httpd.confing | grep User
2)  cat config/httpd.confing | grep Group
3)  see which user and group runs apache container
4)  chown <apache_user>:<apache_group> htdocs -R 
5)  apachectl -k restart

Comments

Popular posts from this blog

Петли L2, методы борьбы (PortFast, LoopGuard, BPDU guard, BPDU filter)

Проброска static маршрута в OSPF

EtherChannel