Archive

Posts Tagged ‘docker’

Using Docker Volumes to Share Data Between Containers and Host Computer

August 4, 2019 Leave a comment

Docker volumes are used to persist data from a certain directory or directories of your Docker containers. So your data is not removed when the container stops or is removed.

You can also share a Docker volume to many containers. Let’s talk about a scenario to find out why it’s important.

Let’s say you have a PHP web application. Now you want to test whether it works on PHP version 5.4, 7.0, 7.1, and 7.2. You can create a Docker volume, let’s call it webapp. Then copy the source code files of your PHP web app to the Docker volume webapp. Then you can create containers of different PHP versions and attach the Docker volume webapp to WEBROOT of all these containers. That way, you can easily test how your web app performs on different PHP versions.

In this article, I will show you how to use Docker volumes to share data between containers and the host computer. Let’s get started.

https://linuxhint.com/docker_volume_share_data/

Advertisements
Categories: Interesting Tags:

Getting MySQL Server Up on a Docker Container

November 16, 2018 Leave a comment

Problem:
I needed mysql-server for a flask tutorial, but I did not want to install it locally on my machine. I opted to give a docker container a shot and get out of my comfort zone of using vagrant boxes.

Solution:
Install the command line mysql client.

$ brew install mysql-client
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.

==> Downloading https://homebrew.bintray.com/bottles/mysql-client-5.7.23.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/8b/8b73614068a82ed9f82f19e52fdd621adcd4d017fc3767703f216cbf7b00e60e?__gda__=exp=1542310178~hmac=5e9
######################################################################## 100.0%
==> Pouring mysql-client-5.7.23.high_sierra.bottle.tar.gz
==> Caveats
mysql-client is keg-only, which means it was not symlinked into /usr/local,
because conflicts with mysql.

If you need to have mysql-client first in your PATH run:
  echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql-client you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql-client/include"

==> Summary
/usr/local/Cellar/mysql-client/5.7.23: 232 files, 80.5MB

$ echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc

Then

$ docker run --name=test-mysql --env="MYSQL_ROOT_PASSWORD=mypassword" --publish 6603:3306 mysql

In another terminal

$ mysql -u root -p -h 127.0.0.1 -P 6603
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

To stop and destroy the containers.

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
ec35ea89e39b        mysql               "docker-entrypoint.s…"   16 minutes ago      Up 16 minutes       33060/tcp, 0.0.0.0:6603->3306/tcp   test-mysql

$ docker stop test-mysql
test-mysql

$ docker rm test-mysql
test-mysql

$ docker ps -a 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Source:
https://severalnines.com/blog/mysql-docker-containers-understanding-basics

Categories: Interesting, MySQL Tags: ,

Running Flask on Kubernetes

October 1, 2018 Leave a comment

Posted by Michael Herman on Sep 19, 2018

In this post, we’ll first take a look at Kubernetes and container orchestration in general and then we’ll walk through a step-by-step tutorial that details how to deploy a Flask-based microservice (along with Postgres and Vue.js) to a Kubernetes cluster.

https://testdriven.io/running-flask-on-kubernetes

Source:
https://pycoders.com

Categories: flask, postgresql, python Tags: , ,

Create a Development Environment with Docker Compose by Mark Ranallo

September 3, 2018 Leave a comment
Categories: Interesting Tags: ,