Docker : When and How to use docker to host odoo ?

Docker ?  What is it ?

 Docker is a platform where you can create an image of your application along with system environment setup. 

• Docker provides container technology, A container platform is a complete solution that allows organizations to solve multiple problems across a diverse set of requirements. It is more than a piece of technology and orchestration - it delivers sustainable benefits throughout your organization by providing all the pieces an enterprise operation requires including security, governance, automation, support and certification over the entire application lifecycle. 

• Docker can use into local machine and also in the cloud.

• Docker is a basic tool, like git or java, that you should start incorporating into your daily development and ops practices. 

• Use Docker as version control system for your entire app's operating system 

• Use Docker when you want to distribute/collaborate on your app's operating system with a tea

• Use Docker to run your code on your laptop in the same environment as you have on your server (try the building tool) 

• Use Docker whenever your app needs to go through multiple phases of development (dev/test/qa/prod, try Drone or Shippable, both do Docker CI/CD) 

• Use Docker with your Chef Cookbooks and Puppet Manifests (remember, Docker doesn't do configuration management)

How Docker Works?

 DOCKER -> CREATE IMAGE -> DOCKER CONTAINER -> DOCKER INSTANCE 

• the image is created of an application, of which an instance will be created from the image and will sit in a docker container of a machine. 

• Docker instance acts like a separate machine and has an IP and ecosystem of its own.

Docker Pros and Cons

                            Pros
                            Cons
• Fast 
• Still hard 
• Well documented 
• Has poor monitoring 
• Public container registries 
• Platform-dependent 
• Containers are small compared to VM
• Containers use fewer resources 
• Eliminating the “Works on My Machine” situation 

• Security 

• They work well in DevOps and CI/CD
• Isolation 

• Networking


How To use Docker to host odoo?


We are going to see How to install odoo in Docker,

  • Update System

 sudo apt-get update
  • Install Docker 

 sudo apt-get install docker.io
  • Start Postgres Server

 sudo docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db postgres:9.4
  • Start Odoo Instance

sudo docker run -p 8069:8069 --name odoo --link db:db -t odoo

(this image will take latest odoo version for other version you need to add odoo:9 ,odoo:10 like this in the end of the command)

  • #version 9 (docker run -p 8069:8069 --name odoo --link db:db -t odoo:9

  • #version 10(docker run -p 8069:8069 --name odoo --link db:db -t odoo:10)

  •   Check Odoo Running

  go to terminal type command "ifconfig", you will see docker0 section, you have to take inet addr to check odoo. 

  • Stop Odoo instance

 sudo docker stop odoo
  • Restart and See log Odoo

 sudo docker start -a odoo
  • Run Multi odoo instance

 sudo docker run -p 8070:8069 --name odoo2 --link db:db -t odoo 	
sudo docker run -p 8071:8069 --name odoo3 --link db:db -t odoo
  • Run odoo with custom configuration File

sudo docker run -v /path/to/config:/etc/odoo -p 8069:8069 --name odoo --link db:db -t odoo
  •  Mount custom addons

docker run -v /path/to/addons:/mnt/extra-addons -p 8069:8069 --name odoo --link db:db -t odoo 	
/path/to/addons = your local custom addons path
/mnt/extra-addons = Docker extra addons path
  •  Check running Docker container

sudo docker ps -a 	
  • Stop and Remove docker container

sudo docker stop container_id 

to remove the container , first, you need to stop the container 

sudo docker rm container_id
  •  Install package into odoo docker

sudo docker exec -u root -it odoo /bin/bash

after this command you will enter into odoo docker instance , there you can install and update packages

  • Move file local system to docker Container

sudo docker cp  /local/path  odoo:/conatiner/path 	

• odoo = Docker container name

  • How to install Font into docker

• you need to move your font file  into docker container 

• first go to docker container

sudo docker exec -u root -it odoo /bin/bash 	

• create font name folder in  /usr/share/fonts/truetype/Avenir 

• move your local font file to docker container 

sudo docker cp  /usr/share/fonts/truetype/avenir/Avenir-Book.ttf odoo2:/usr/share/fonts/truetype/Avenir/


Docker Commands


Run docker command on terminal

You can see some different options after run docker.

  • Docker  --version
    

To check docker version

  • Docker info 
    

Gives you system information like docker directory, RAM,CPU, version

  • Docker Images

Gives you a list of images

Options

--all , -a         Show all images (default hides intermediate images)

--filter , -f     Filter output based on conditions provided

--digests       Show digests

--format       Pretty-print images using a Go template

--no-trunc   Don’t truncate output

--quiet , -q   Only show numeric IDs

Docker container commands


  • docker container attach 
    

Attach local standard input, output, and error streams to a running container

  • docker container commit 
    

 Create a new image from a container’s changes

  • docker container cp 
    

Copy files/folders between a container and the local filesystem

  • docker container create 
    

Create a new container

  • docker container diff 
    

 Inspect changes to files or directories on a container’s filesystem

  • docker container exec 
    

 Run a command in a running container

  • docker container export 
    

Export a container’s filesystem as a tar archive



  • docker container inspect

Display detailed information on one or more containers

  • docker container kill
    

 Kill one or more running containers

  • docker container logs 
    

Fetch the logs of a container

  • docker container ls 
    

List containers

  • docker container start
    

Start one or more stopped containers

  • docker container stop 
    

Stop one or more running containers

  • docker container top

Display the running processes of a container

  • docker container update 

Update configuration of one or more containers

  • docker ps -a
    

Gives you a list of running containers

  • docker start container_name 

Starts one or  more stopped container

  • docker stop container_name 

Stop one or  more  container

  • docker restart container_id 

To restart container

  • docker run -it -d image_id 
    

Docker Run commands create container from image 

  • docker pull 

Pulls an image or a repository from a registry 

  • docker push 

Pushes an image or a repository to a registry 

  • docker commit 

Creates a new image from a container’s changes 

  • docker search 

It searches Docker hub from the images 

  • docker rename

To rename container name

  • docker rm container_id

To remove container

  • docker rmi image_id

To remove Images

  • docker service command

To manage docker services

  • docker service create 

create new service

  • docker service inspect 

Display detailed information on one or more services

  • docker service logs 

Fetch the logs of a service or task

  • docker service ls 

List services

  • docker service ps 

List the tasks of one or more services

  • docker service rm 

Remove one or more services

  • docker service rollback 

Revert changes to a service’s configuration

  • docker service scale 

Scale one or multiple replicated services

  • docker service update 

Update a service

  • docker config command

Manage Docker configs

  • docker config create 

Create a config from a file or STDIN

  • docker config inspect 

Display detailed information on one or more configs

  • docker config rm 

Remove one or more configs

  • docker config ls 

List configs

  • docker checkpoint

To Manage checkpoints

  • docker checkpoint create 

Create a checkpoint from a running container

  • docker checkpoint ls 

List checkpoints for a container

  • docker checkpoint rm 

Remove a checkpoint

  •  docker login [OPTIONS] [SERVER]

Log in to a Docker registry

Docker : When and How to use docker to host odoo ?
Divya Vyas
17 February, 2020
Share this post
Tags
Edit
Archive
Sign in to leave a comment
Linux command that every odoo user should know