Sunday 16 June 2019

Get started with Docker for Windows + Odoo

        Docker is a full development platform for creating containerized apps, and Docker Desktop for Windows is the best way to get started with Docker on Windows.
          Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

See Install Docker Desktop for Windows for information on system requirements and stable & edge channels.
Open a terminal window (Command Prompt or PowerShell, but not PowerShell ISE).
  1. Run docker --version to ensure that you have a supported version of Docker:
    > docker --version
    
    Docker version 18.03.0-ce, build 0520e24
    
  2. Pull the hello-world image from Docker Hub and run a container:
    > docker run hello-world
    
    docker : Unable to find image 'hello-world:latest' locally
    ...
    
    latest:
    Pulling from library/hello-world
    ca4f61b1923c:
    Pulling fs layer
    ca4f61b1923c:
    Download complete
    ca4f61b1923c:
    Pull complete
    Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    ...
    
  3. List the hello-world image that was downloaded from Docker Hub:
    > docker image ls
    
  4. List the hello-world container (that exited after displaying “Hello from Docker!”):
    > docker container ls --all
    
  5. Explore the Docker help pages by running some help commands:
    > docker --help
    > docker container --help
    > docker container ls --help
    > docker run --help
Configuring Odoo

For configuring Odoo we have to first setup PostgreSQL image on docker and link that to the Odoo.


// pulls the PostgreSQL image from docker hub docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db postgres:9.4
// pulls the Odoo image from docker hub and linking to PostgreSQL docker run -p 8069:8069 --name odoo --link db:db -t odoo // pulls the Odoo 10 image from docker hub and linking to PostgreSQL
docker run -p 8069:8069 --name odoo --link db:db -t odoo:10
In above code the --name is the name of the docker container. We can use that to start and stop the container. -p is the port no: that docker needed to expose to outside.

For start and stop servers we can use the following commands. After you run docker runcommand once don't run it again, unless you are planning for multiple instance of Odoo. Use below commands instead. Because it will download latest version again and will occupy more space.

docker start odoo // start the odoo
docker stop odoo // stop odoo container

Now you can check the Odoo running on:8069

Also, here is some useful command when we are using docker

For Buid New image:

> docker build -t "New Image Name" "path of docker file"

For Execute command and Connect to image:

> docker exec -it "image name" bash //Enter in the image or
> docker exec -it "image name" pip3 install xlrd // Install Package














3 comments: