Tag: python

Access Host redis database from docker conatiner

I am trying to connect to host redis database through my docker conatiner. In my dockerfile , I have redis as a requirement, which gets installed [pip install redis] and image is build using that docker file. After than I instantiate the conatiner using following command sudo docker run -p 6543:6543 your_image_name my app.py is […]

Why is my Redis Python setup inserting values multiple times when a command is called once?

I’m trying out Redis and i’m not sure where i’m going wrong with my setup when r.lpush() is called I assume it would insert a value into my list and lengthen the list by one but when llen() is called the length increases by a random amount each time I run this script import redis […]

Opening file from Docker Container in Python/Django Web App

I have create a docker container which specifies WORKDIR /usr/src/app Inside my Django web app, I try to access file_path = ‘/usr/src/app/management_app/mock/printable-profile.json’ File “/usr/src/app/management_app/urls/__init__.py”, line 5, in <module> app_1 | from ..views import views app_1 | File “/usr/src/app/management_app/views/views.py”, line 13, in <module> app_1 | json_data = open(file_path) app_1 | FileNotFoundError: [Errno 2] No such file […]

SSH to backend app

I have a lot docker containers and my idea is to have one ssh server and when type ssh <containerid>@myserver it actually do docker attach to specific container. What I need is way how to after running someuser@host runs python script which make a tunnel to docker container. Same way git works using SSH.

Docker Mac Beta and container connecting to host ports?

I currently use PyCharm (Actually IntelliJ) and have been using Kitematic with VirtualBox support. I have a container connecting to the host (which is a virtual machine) to do remote debugging. The issue is when I try to use Docker Mac Beta, the container doesn’t seem to be able to access any specific ports on […]

docker/matplotlib: RuntimeError: Invalid DISPLAY variable

I tried lots of solving method, none of them worked. I tried echo $DISPLAY not working Error Message: Environment: Request Method: GET Request URL: http://10.231.xx.xx:8000/upload/ Traceback: File “/opt/conda/lib/python2.7/site-packages/django/core/handlers/base.py” in get_response 149. response = self.process_exception_by_middleware(e, request) File “/opt/conda/lib/python2.7/site-packages/django/core/handlers/base.py” in get_response 147. response = wrapped_callback(request, *callback_args, **callback_kwargs) File “/code/fileUpload_app/views.py” in msa_result 174. result1 = generate_hist(db, **processing_dict) File […]

Ansible prompt_vars error: GetPassWarning: Cannot control echo on the terminal

I am using Ansible and Docker for automating the environment build process. I use prompt_vars to try to collect the username and password for the git repo but unfortunately i got this error: GetPassWarning: Cannot control echo on the terminal The docker ubuntu version is 14.04 and python version is 2.7

Dockerfile not able to build on Ubuntu 14.04 but does fine on Windows 10 and Ubuntu 16.04

I have the following Dockerfile – FROM ubuntu:16.04 RUN apt-get update -y && apt-get install -y \ python-pip \ python-dev \ python-lxml \ build-essential \ qt5-default \ libqt5webkit5-dev \ xvfb \ git RUN pip install –upgrade pip && pip install \ lxml \ xvfbwrapper \ flask \ bs4 \ dryscrape # copy all files to […]

Python inside Docker cannot print unicode without –tty

I’m trying to run a simple Python app in Docker, using the official python:2.7 image. My problem is that unless I enable -t / –tty in docker run, the python print command terminates when trying to print Unicode characters: UnicodeEncodeError: ‘ascii’ codec can’t encode characters… If I enable –tty it works without errors. The problem […]

Docker image gives me “executable file not found in $PATH” when run from python

I’m trying to run some commands inside a docker image in python. When I do: docker run –rm -v <some_dir>:/mnt –workdir /mnt frolvlad/alpine-oraclejdk8:slim sh -c “javac example.java && java example” In console (kali linux) it runs fine and prints the result. When I try to run same command from python it gives me the error: […]

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