Tag: python

Mariadb docker container Can't connect to MySQL server on host (111 Connection refused) with Python

I am trying the connect mariadb with python using docker-compose: docker-compose.yml version: ‘2’ services: mariadb: image: bitnami/mariadb ports: – “3306:3306” environment: MARIADB_DATABASE: ‘mary_db’ MARIADB_USER: user2 MARIADB_PASSWORD: ‘pass1234′ consumer: build: ./consumer links: – mariadb consumer.py import mysql.connector as mariadb1 mariadb_connection = mariadb1.connect(host=’mariadb’, port=3306, user=’user2′, password=’pass1234′, database=’mary_db’) cursor = mariadb_connection.cursor(buffered=True) try: cursor.execute(‘DROP TABLE names’) except: pass comm […]

Running a docker container to execute python script with minimal footprint

I have a node.js server that gets an python script as an input from the web client (Yes, risky), the server runs the script and return the output to the client. In order to minimize the risks here, I’m creating a docker container for the execution of the script with the following command: docker run […]

APScheduler running a Python Script

I have a python script which is a scraper. I want it to run every 10 minutes. Currently it is in its own docker container and with EntryPoint to a python file. def main(): scheduler = BlockingScheduler() scheduler.add_job(scraper, ‘interval’, seconds=600) scheduler.start() This works fine for about 2 weeks but then stops and I am required […]

Simple Flask application with debug set to True is not reloading in Docker?

New to Docker, I have my Python/Flask service working trial-api but it does not reload the files when I change the code like it normally does (when not used through Docker.) Meaning, I’ve got to delete the image and rebuild it all the time. What’s the right way to do it? docker-compose.yml: version: ‘2’ services: […]

Find container size using python sdk

I was searching for an API in sdk python for docker in which I could find the size of the container. I have been searching for two days, but I did not get the solution. I am not talking about the image size out here, I want specifically the container size. If anyone here has […]

Docker, python, work with multiple dockers simultaneously, like building blocks

Is it possible to work with multiple docker images or containers simultaneously, like building blocks? For example: I’ve 1 docker file, which can be used as a stand alone thing. What it does is: (python) It receives an input (python flask), uses a python script to modify the input and gives an output back (POST). […]

Process still alive after docker kill container

I use docker to run python programs, when I killed container by “docker kill container name” Some processes are still alive , and got nothing using “docker ps” Did someone encounter this situation ? Client: Version: 1.12.1 API version: 1.24 Go version: go1.6.3 Git commit: 23cf638 Built: OS/Arch: linux/amd64 Server: Version: 1.12.1 API version: 1.24 […]

python creating directories and writing files inside docker container

I am writing a docker file of an existing python script. My docker file : FROM python:2.7.11 ADD ./ test_project/ RUN mkdir /test_project/download/ RUN chmod -R 777 /test_project/download WORKDIR test_project RUN ls -ltr CMD [ “python”, “report/test.py”]` Part of my python script test.py that creates the directory and subdirectories os.makedirs(download_directory) Here “download_directory” = /test_project/download/reports/2017-01-24/ When […]

Docker container with Flask server stops responding after around 20 requests

I have a docker container that takes in URL to an image, downloads the image to memory using urllib2, does some processing to it using Tensorflow, and returns back with JSON data. The code is structured as follows: myapp.py from flask import Flask from flask_restful import reqparse, abort, Api, Resource, inputs import my_tensorflow app = […]

Debugging silent failure in Gunicorn/NGINX/Django

I’m running a Django project with Gunicorn. I’m using Nginx as a reverse proxy. For the most part, everything works fine, but there’s one Django view that causes Gunicorn to fail silently. Details of the problem are below, but first, here’s the Django view that’s causing the problem: def jobs_all(request): if not request.user.is_superuser: raise Http404 […]

Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.