Docker First Impressions

in #docker6 years ago

So, I keep hearing all this riff raff about Docker. How's it's the greatest thing since sliced bread. (Which I find really insulting to sliced bread, that's an epic invention. :P ). So, I decided to give it a go.

Docker

So the for dummies definition of what docker is. It's mix between a VM and a chroot environment. You can read all the technical details on their site, but the general idea is that it sandboxes your application in a container. Your container can also be made to mimic your production environment. So you can deploy and run your apps on a CentOS, Fedora, etc.. environment. It gets rid of the .. 'oh but it worked on XXX why isn't working on YYY'

First gem was: https://hub.docker.com/ You visit the website, search for your favorite app and pull it down. Everything is honkey dorey.

Most of them have instructions along these lines:

docker pull mysql

docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag

or some other set of options that exposes the mysql port to your environment and you can use it as you see fit.

The CLI options are handy but can get a bit verbose and annoying as you do more and more with it. I'm sure they have something better don't they?

Docker Compose

Formerly known as fig.

This is an example config.

www:
  build: .
  links:
   - db
  ports:
   - 8080:8080
   - 8443:8443
db:
  build: docker_builds/mydb
  ports:
    - 5432:5432

The build: tag references instructions on how to build an image. It's essentially a set of instruction you add on top of a base image. So I can say.. get ubuntu server, then install JDK7 and tomcat and call it my_ubuntu_tomcat

The really nice part about this application (docker compose) is that in theory it allows me to link applications together.

I can add various components together and wire up and environment and replace blocks with whatever I want. The part that's a bit annoying (to me ) is that these are not all running on the same host.

So you have to play around with your app and do some magic. For example $DB_PORT shows me tcp://172.17.0.126:5432 (default postgres port and IP).

so, now I have to wire all the env. variables together to make all of these applications aware of one another, or code with the idea that they would read from some ENV variable.

It would be nice if when linked, they would all pretend to be on localhost. Or at least have a local mode.

Some servers and configs are a pain to make aware of ENV variables and we end up doing some ugly sed / awk magic to get this working.

I'm still a bit green, so maybe someone can enlighten me. But this looks like a nice idea which needs a bit more polish to make it fully usable.

Any thoughts?

Sort:  

docker-compose by default sets up a user-defined network for the services so they can talk to each other using the service name (so you don't need to find out their IP).
If you really wanted however you could setup multiple containers with the same network stack (breaking some of the isolation. With this setup other containers can access them via their ports through localhost but that also allows them to see all of their network traffic.
Example: https://pastebin.com/raw/U7CHqQFf
Have a look at https://docs.docker.com/compose/networking/ and https://docs.docker.com/compose/compose-file/#network_mode

Yeah, this was my first take on docker. It's pretty dated and overly complicated. The IP is the name of the service though configuring the app via ENV would be needed still. Essentially https://12factor.net/ is very helpful to getting docker to work well with your app.

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 60115.50
ETH 3192.77
USDT 1.00
SBD 2.45