I'm attempting to search docker hub for images using the command "docker search", via python code.
here is the piece of code for this action:
client = docker.from_env()
image_list = client.images.search('ubuntu')
running this in the command line works, and also running it via flask locally works.
however, when deploying to heroku, this crashes the site, and the logs say the following:
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
which basically tells me docker isn't installed on the machine running docker.
I found this question:
Running Docker inside a Python app on Heroku?
but it wasn't answered and basically describes what I need.
any idea what I can do in this situation? thanks!
Related
In the Python Docker SDK, When I do
import docker
docker.from_env()
I see
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
I have docker desktop running and this works in the terminal
$ docker run -it ubuntu
If I add a version number
docker.from_env(version="6.0.1")
it stops erroring, but it doesn't seem to matter what number I use. I also then see an error on
client.containers.run("ubuntu")
of
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
I'm on Ubuntu 22.04 and I'm seeing the problem with both Poetry and plain pip + venv. I've looked through the dozen or so questions about that error message and tried everything that looked relevant.
My final solution was to uninstall Docker Desktop and install Docker Engine instead. I had to manually delete some Docker config files left over after installation too.
I'm new to application development and decided to use AWS services for this project. however, I am having difficulty deploying chalice. every time I run "chalice deploy", I get an error.
here are the steps I followed along with commands for Windows:
upgraded my powershell
"virtualenv enve" : then ".\venv\Scripts\activate" # install and run virtual environment
"pip install aws cli" : # install aws command line interface
"aws configure" : # configure my AWS_KEY and AWS_SCERET
"pip install chalice" : # install chalice
"chalice new-project": # created a new project
"chalice deploy" # deploy
I get
An error occurred (InvalidClientTokenId) when calling the GetRole
operation: The security token included in the request is invalid.
I'm able to use localhost and run my application but not able to deploy to the server. I don't know what i'm doing wrong. someone, please help!
additional info:
my operating system is windows 10. I upgraded my PowerShell to 7
I somehow figured it out!. The error occurred because the command "
chalice deploy
" was used in the wrong directory. Make sure you are in the directory where your chalice file is before initializing it to deploy.
I'm writing below script which will build docker image and then push it to ECR.
Here, in this snippet I'm posting the error while building the image. This is in Window OS local machine and python version is 3.8.0
I have below folderstructure:
/home:
-->ECR
-->buildImage.py
Dockerfile
The script /home/ECR/buildImage.py looks like this:
import docker
docker_api = docker.APIClient()
dockerfile_path = os.path.dirname(os.getcwd())
print("Docker file location: " + dockerfile_path)
if os.path.isfile(dockerfile_path + "\\Dockerfile"):
print("File exists")
else:
print("File does not exist...")
docker_api.build(path=dockerfile_path, tag=local_tag, rm=True, dockerfile=".\\Dockerfile")
This above throws me error:
pywintypes.error: (2, 'WaitNamedPipe', 'The system cannot find the file specified.')
and with this one,
docker_api.build(path='dockerfile_path', tag=local_tag, rm=True, dockerfile=".\\Dockerfile")
this throws me
TypeError: You must specify a directory to build in path
How can I fix this? Is it necessary that on your local machine which in my case in Window Docker should be available? Docker is not installed but docker python package version 4.1.0 is installed.
print(docker.__version__)
>> 4.1.0
You need to have the Docker Engine installed as well. This is a Python API for the Docker Engine, so it is just using the source code from your local Docker through a python interface. Furthermore, your version of API needs to match your Docker engine SDK.
From the docs:
Versioned API and SDK
The version of the Docker Engine API you should use depends upon the version of your Docker daemon and Docker client.
A given version of the Docker Engine SDK supports a specific version of the Docker Engine API, as well as all earlier versions. If breaking changes occur, they are documented prominently.
Daemon and client API mismatches
The Docker daemon and client do not necessarily need to be the same version at all times. However, keep the following in mind.
If the daemon is newer than the client, the client does not know about new features or deprecated API endpoints in the daemon.
If the client is newer than the daemon, the client can request API endpoints that the daemon does not know about."
Has anyone had experience deploying a Django app on Heroku that contains a script within it?
I'm currently building a web app that works as a front end tool to a couple of python bots that I have been creating during the years, as well as for personal useful tools (Scripts). The issue is that I've been trying to deploy my app on Heroku and test the functionality of running my Tinder Bot from within Heroku, but I have not been successful, i'm currently getting errors such as:
"unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist"
Thing's that I've done to try to solve the issue:
1- Setting the chrome arguments as:
chrome_settings = Options()
chrome_settings.add_argument('--headless')
chrome_settings.add_argument('--no-sandbox')
chrome_settings.add_argument('--disable-dev-shm-usage')
As well as setting the directories for chrome binary and chromedriver to:
GOOGLE_CHROME_BIN = '/app/.apt/usr/bin/google-chrome'
path_of_chrome_driver = '/app/.chromedriver/bin/chromedriver'
But I am still getting the same error. Would anyone know whats the proper procedure to create a web app that can contain python scripts in it, and to be deployed on Heroku?
Ps: I have followed the steps to set up (Whitenoise and gunicorn) for heroku deployment.
Requirements:
Django==2.1.1
gunicorn==19.9.0
pytz==2018.5
selenium==3.14.1
urllib3==1.23
whitenoise==4.1
This is the site I am developing: https://bot-tools-collection.herokuapp.com/
Update
Link to the code:
https://gist.github.com/keithlowc/d0b274005ecf9d41b4f087620b487dc5
I'm trying to dockerize a python/django application. When Docker runs the build script in a web container, it is unable to retrieve the images from application.
It shows an error:
and on Google chrome console it shows:
But what is interesting is that I don't get any errors when I do the same on my local machine.
Everything goes as expected.
Docker version 18.03.1-ce, build 9ee9f40