Docker compose How to run local pubsub inside docker? Here is a docker compose file that will: pull in the google/cloud-sdk:emulators image initialize the project with id test-project-id create topic with name test-v1-topic create subscription with name test-v1-subscription version: '3.8' services: pubsub-emulator: image: google/cloud-sdk:emulators container_name: pubsub-emulator ports: - "8085:8085" command: gcloud beta emulators pubsub start … Continue reading Local pubsub emulator via docker compose && Spring Boot
Category: Docker
Keycloak docker KC_ variables ignored?
I have been using the `quay.io/keycloak/keycloak:19.0.3-legacy` with docker compose and JHipster. Now, JHipster application exposes UI to 8080, keycloak also exposes to 8080, so we map it to another port, say 9080. JHipster app talks to the keycloak via service name and port, like so: keycloak:8080, and all works fine until you try to login, … Continue reading Keycloak docker KC_ variables ignored?
Docker image layers
Docker images are layer based - layer based architecture. Each step (instruction) from a Dockerfile creates a layer. These layers are cached and reused next time the image is built. Lets see one Docker file for a node.js app: FROM node:12 WORKDIR /app COPY . /app RUN npm install EXPOSE 80 CMD [ "node", "server.js" … Continue reading Docker image layers
Multi-stage docker images
When working with docker images, it would be a good idea to keep the final image (especially for production) as small as possible. Usually, when building apps, there are a lot of extra stuff included that are really not necessary for the final image. This can be most obvious with Spring Boot applications, where build … Continue reading Multi-stage docker images
Docker volume on host machine – write access and shared permissions
Using docker for running all kinds of reports (reporting applications, such as performance tests or penetration tests etc.) in the CI is a common practice. However, sometimes you'd have to cleanup the report directory in order to create a new one. When running applications inside a docker, usually they will run as root and files … Continue reading Docker volume on host machine – write access and shared permissions
Run WordPress inside Docker?
By using docker-compose, you can run WordPress site with one command. TLDR: https://github.com/divukman/wordpress-docker docker-compose.yaml: version: '2' services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: wordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_PASSWORD: wordpress volumes: db_data: Running $ docker-compose … Continue reading Run WordPress inside Docker?
Run SpringBoot app inside alpine docker container
# From alpine:latest FROM alpine # Install open JDK 11 RUN apk add openjdk11 # Create temp volume VOLUME /tmp # Add and run your app ADD /spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/myapp.jar"] Build the image: docker build -t alpine-java-3 . Run the image, map the ports 8080 to host machine: docker run -d … Continue reading Run SpringBoot app inside alpine docker container
Docker – Copy file from container to host directory
Ok, so here is one very common question. How do I copy file from a docker image instance (container) to a host file system? Why? One common scenario would be, for example, running a continuous integration server and running Cucumber tests. Once you generate the HTML report, you'd like to copy the file to host … Continue reading Docker – Copy file from container to host directory
Run SpringBoot application in Docker image
This is a short recipe on how to run your spring boot application within a docker image. The idea comes from John Thompson's docker for java developer course, so be sure to check it out here https://www.udemy.com/docker-for-java-developers/. What do we want to accomplish? Create a fat (uber) jar of our applicationCreate a Docker file (a … Continue reading Run SpringBoot application in Docker image
MySQL on Docker
This is a short recipe for starting the MySQL on Docker. I have Windows 10 machine now and run Docker natively (no Linux VM). Run the following command: docker run --name dimitar-mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -v C:/DockerContainersData/mysql:/var/lib/mysql -p 2000:3306 -d mysql --name: give it whatever you want-e MYSQL_ALLOW_EMPTY_PASSWORD=yes: allow empty root password-v C:/DockerContainersData/mysql:/var/lib/mysql: to keep the … Continue reading MySQL on Docker