By Tomche Delev / @tdelev
According the official docs Docker is a platform that can be used to
Downsides of VM aproach are:
Docker is becomingly
Allows you to package a microservice in a
that’s independent of the technology used to implement the service
Provides a
between different services
Docker containers are
and as a result can be built and
It runs natively on
You can also run Docker on Windows and Mac OSX using
Some clouds also have added extra support for Docker
The two main Docker concepts are
which is a portable application packaging format
which is a running image and consists of one or more sandboxed processes
A Docker image is read-only file system image of an operating system and an application.
An image is
and will run on any Docker installation
You can create an image from scratch
but normally an image is created by starting a container from
installing applications by executing the same kinds of commands you would use when configuring a regular machine
and then saving the container as a new image
For example, to create an image containing a Spring Boot based application, you could start from a
and then
A Docker container is a running image consisting of one or more sandboxed processes
Docker container often only consists of the application’s processes
Let’s now build a Docker image that runs the Spring Boot application
FROM java:8
COPY demo-prod.jar /apps/spring_app/
WORKDIR /apps/spring_app
EXPOSE 8080
CMD ["java", "-jar", "demo-prod.jar"]
$ docker build -t tdelev/spring_app .
$ docker pull postgres
$ docker create -v /var/lib/postgresql/data \
--name spring_app_data postgres:9.4
docker run --volumes-from spring_app_data \
--name spring_app_pg \
-e POSTGRES_USER=demouser -e POSTGRES_PASSWORD=demopass \
-d -P postgres:9.4 \
To connect to the database execute
docker run -it --link spring_app_pg:postgres \
--rm postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" \
-p "$POSTGRES_PORT_5432_TCP_PORT" -U demouser' \
create database demo;
docker run --name spring_app_container \
--link spring_app_pg:spring_app_pg \
-p 8080:8080 \
-d tdelev/spring_app
Connect to database instance
psql -h localhost -p 49157 -U demouser --password