Skip to main content

Posts

Showing posts from April 8, 2019

Docker - Networking

Greetings! When we talked about Docker, we said that containers are isolated. Then how do we communicate with our containers. Say we are using MySQL database. It is not useful if we can't access it. Docker has a network concept. It has several network drivers to work with. Depending on how do we want out container to behave, we can select our network. This help us to communicate container with a container or container with host. Network commands summary docker network ls - list available networks docker network create - create a network docker network rm - remove a network docker network inspect - inspect a network docker network connect - connect container to a network docker network disconnect - disconnect container from a network Docker network drivers bridge - This is the default network. When the Docker daemon service starts, it configures a virtual bridge names docker0. When we don't specify the network this is the one docker uses. Docker creates

Docker - Volumes

Greetings! Sharing is caring. When the container is running/down or removed we need to access the data within it. Be it a database, web application logs it needs to share some form of data with host or with the other containers. Docker provides volume to achieve this. Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. Volume commands docker volume create - create a volume docker volume ls - list available volumes docker volume remove - remove a volume docker volume prune - remove all unused volumes docker volume inspect - inspect a volume Create a volume docker volume create my-volume List volumes docker volume ls Inspect a volume docker volume inspect my-volume Remove a volume docker volume rm my-volume Remove all unused volumes docker volume prune Start a container with a volume We can start a container with a volume using --mount or -v flag. As in the docs, New users should try --mount syntax

Docker - Images and Containers

Greetings! Docker image to container(s) Image An image is a read-only template with instructions for creating a Docker container. It is a combination of file system and parameters. Often, an image is based on another image with some additional customization. We can use existing images or create our own images. Container A container is a runnable instance of an image. We can create as many as we want from an image. Container is isolated from the host by default. We can modify it's behavior using network, volume, etc. When a container is created, we can stop, restart, remove it. Download an Image We can download a Docker image using 2 methods. pull - we can use pull command to get an image $ docker image pull nginx create a container - when we create a container from an image, it downloads the image from the repository if it is not available in the host. $ docker container run nginx Docker command structure There are many commands. So Docker has group

Docker - Introduction

Greetings! Let's talk about Docker container ;) The Problem Software packaging, distribution, installation is not that easy. It is true that there are easy to use software packages. Normally software depends on other libraries. To install a software it needs to install those dependencies first. What if those libraries have other dependencies? What if there are version conflicts? Let's see a picture of a software installation. It is a web of libraries. Now imagine we need to uninstall our software. Will it remove it's dependencies properly. Will that have an impact on other software? How do we install another version? What if you need to main multiple computers with this same setup? There are many questions though we can somehow solve. Imagine time, energy we spend on these. Is it worth? Lets say we want install MySQL as the database. Why do we need to spend lot of time for that when our main task is something else. These are reasons we need to find other w