Docker
Docker
Imagine that Docker is like a big ship carrying containers. Well, inside the
containers will contain the merchandise. Hypothesize that the merchandise
are "Docker images", so structure of docker similar :
👍So now let's see how containers solve some of these problems with
containers. With containers, you actually do not have to install any of the
services directly on your operating system. Because the container is own
isolated operating system layer with Linux based image. So you have
the PostgresSQL, pakage with a configuration in the start script inside
of one container. And the download step is just one docker command which
fetches the container and starts it at the same time. So we have 10
applications that your Javascript application uses and depends on, you would
just have to run 10 docker commands for each container and that will be it.
Which makes the setting up your local development enviroment actually
much easier and much more efficient than the previous version.Also, you can
actually have different versions of the same application running on your local
environment without having any conflict.
Docker virtualize is the application layer. So, when you dowload a docker
image, it actually contains the applications layer of the operating system and
some other applications installed on top of it. And it use the kernel of the
host because it doesn't have its own kernel.
Virtual Machine (VM) has the applications layer and its own kernel, so
virtualize is the complete operating system, which means that when you
download a virtual machine image on your host, it doesn't use your kernel. It
puts up its own.
So what is this difference between Docker and Virtual Machine actually mean
? So first of all, the size of Docker images are much smaller because they just
have to implement one layer. A second one is the speed so you can run and
start docker container much faster than VM. The third difference is
compatibility.
Installation docker
Docker can install on the multiple flatforms, such as : Mac, Linux, Window.
Link tutorial Iam working with deep learning then by default you use ubuntu.
Detail description install : link
ca-certificates \
curl \
gnupg \
lsb-release
$ echo \
3. Inspect install
If result is " Hello from docker ", the installation was successful.
docker login
docker tag <container_name> <user_name>/<responsitory>:<tag>
docker push <user_name>/<responsitory>:<tag>
Build docker
Structure :
1. Build Dockerfile
Dockerfile is used to create an image for our application. This image will run
on any host or environment with Docker installed.
Let's have an overview of whats in our Dockerfile:
FROM: A Dockerfile must start with a From instruction with an
argument that has anather image.
FROM okwrtdsh/anaconda3:cpu
WORKDIR /app
EXPOSE: Port
COPY: This command copies files from the local system onto the
Docker image.
COPY ./app
CMD ["python3","app.py"]
Eg Dockerfile: