Skip to content

Latest commit

 

History

History
125 lines (75 loc) · 3.91 KB

step4.en.md

File metadata and controls

125 lines (75 loc) · 3.91 KB

STEP4: Run the application in a virtual environment

In this step, we will learn how to use Docker.

📖 Reference

1. Run Docker commands

Make sure that you're in mercari-build-training-2022/ directory, and run the following command.

$ docker run -v $(pwd)/data/text_en.png:/tmp/img.png wakanapo/tesseract-ocr tesseract /tmp/img.png stdout -l eng

What message was diplayed after running this command?

Running this command downlods the corresponding docker image from the registry to your local machine.

This docker image has a functionality to read texts from images (OCR). Using a docker allows you to run applications using an environment built within the docker image without altering your local system.

$ docker run -v $(pwd)/data/text_ja.png:/tmp/img.png wakanapo/tesseract-ocr tesseract /tmp/img.png stdout -l jpn

Check if the texts are correctly picked up using any image of your choice containing English or Japanese texts.

🔰 Points

2. Get Docker Image

Run the following command.

$ docker images

This command shows the list of images existing on your local host. You can see that the image we used in the previous step called wakanapo/tesseract-ocr is listed here.

Run the following command and see different types of Docker commands

$ docker help

Docker will download images automatically if they are not found on your local system. You can also download the image beforehand.

Look for a commmand to download an image from the registry and download an image called alpine

Check that you can see alpine in the list of images.

📖 Reference

🔰 Points

Make sure you understand the following commands and when to use them.

  • images
  • help
  • pull

3. Building a Docker Image

Build the docker file under the directory python/ if you're using Python and go/ if you're using Go.

  • Set the name of the image to be build2022/app with latest tag.

Check that you can now see build2022/app in the list of images.

📖 Reference

4. Modity Dockerfile

Run the docker image you built in STEP4-3, and check if the following error shows up.

docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "python": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container: context canceled 

"python" part will be replaced with "go" if you're using Go.

Modify the dockerfile so that you can use the same version of Python/Go as STEP2 in your docker image.

Run the image with the modified dockerfile, check if the same message is displayed as STEP2-2.

📖 Reference

5. Run the listing API on Docker

The environment within the docker image should be the same as STEP2-2 after STEP4-4.

Mofify dockerfile to copy necessary files and install dependencies such that you can run the listing API on docker

$ docker run -d -p 9000:9000 build2022/app:latest

Check if the above command results in the same response as STEP3.


🔰 Points

Make sure you understand the following concepts

  • images
  • pull
  • build
  • run
  • Dockerfile

Next

STEP5: Implement a simple Mercari webapp as frontend