Tag Archives: docker

mountebank for mocking and stubbing http services (rest+graphql+grpc)

http://www.mbtest.org/docs/api/stubs can be used to stub http(s)/tcp/smtp protocols. And has community plugins for grpc, graphql, websockets. You can configure it with imposters.ejs like below: { «port»: 80, «protocol»: «http», «defaultResponse»: { «statusCode»: 404, «headers»: {} }, «stubs»: [ , , ] } docker-compose.yml version: «3.5» services: mountebank: container_name: mountebank image: jkris/mountebank:latest volumes: — ./:/mountebank ports: …

Read more

Docker and Kubernetes basics for developers

Docker Docker containers are much more lightweight compared to classic VMs as they leverage host OS instead of starting their own OS. Containers are using 2 features of Linux-based OS: Namespaces and Cgroups (Control Groups). Namespace Lets you allocate resources in an isolated environment (like a sandbox). On a container start, docker daemon generates a …

Read more

Fixing docker does not want to update images

If you run docker pull, and you see an error like failed to register layer: Error processing tar file(exit status 2): fatal error: runtime: out of memory, there could be 2 reasons. Obvious one — not enough disk space for docker. You can fix it with docker system prune -af docker volume ls -qf dangling=true …

Read more

Create SQS queues on localstack container start

Put this file to your filesystem as ←anyname.sh→: #!/usr/bin/env bash set -euo pipefail # enable debug # set -x echo «configuring sqs» echo «===================» LOCALSTACK_HOST=localhost AWS_REGION=eu-central-1 # https://docs.aws.amazon.com/cli/latest/reference/sqs/create-queue.html create_queue() { local QUEUE_NAME_TO_CREATE=$1 awslocal —endpoint-url=http://${LOCALSTACK_HOST}:4566 sqs create-queue —queue-name ${QUEUE_NAME_TO_CREATE} —region ${AWS_REGION} —attributes VisibilityTimeout=30 } create_queue «queue2» create_queue «queue1» For instance, ./localstack_bootstrap/sqs_bootstrap.sh. Don’t forget to run chmod …

Read more

Using tcpdump for k8s pods

You need wireshark to be installed on your local machine — download (more on this below). If you don’t have tcpdump installed inside the pod, you can install it with # get pod name kubectl get po -Lversion,cfg,infra-cfg -lapp= kubectl exec -it sh # inside the pod, alpine apk add tcpdump Then, on your local …

Read more

Datadog in a docker for integration tests and local dev

DOCKER_CONTENT_TRUST=1 docker run —rm —name dd-agent -p 8126:8126 -v /var/run/docker.sock:/var/run/docker.sock:ro -v /proc/:/host/proc/:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e DD_API_KEY=REPLACE_WITH_NEW_KEY -e DD_SITE=datadoghq.eu datadog/agent

mmock for mocking microservices

It is a very easy to set up though pretty powerful tool with support for delays and handling query params. It also has a console for checking all the requests and corresponding responses matched. Here it is https://github.com/jmartin82/mmock. Below I describe a way to use it with docker-compose for local development.

XDebug inside a docker container

That’s how you can debug your php app running in a docker container.

Integration tests with testcontainers-go

Here is the go library that simplifies integration tests with docker containers — https://github.com/testcontainers/testcontainers-go. That’s how you can use it to test sql — https://github.com/testcontainers/testcontainers-go/blob/master/docs/examples/cockroachdb.md. Project documentation — https://golang.testcontainers.org/features/docker_compose/ The idea is to prepare the environment, build your app, then make requests and check the DB state.

Read logs from docker container

tail -f `docker inspect —format='{{.LogPath}}’ [containername]`