I created a web app and hosted it on Heroku a while ago. I basically wrote a dockerfile with all the instructions and followed steps like here. I just now opened my old laptop and made changes to some of the code. I tried to follow the same steps as usual to push changes, but when I run heroku container:push web -a bluebird-teaching (the app is called bluebird-teaching), I get a strange error.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I made sure that I'm logged in on Heroku CLI and my app still runs. The name of the app on Heroku is indeed the same name I'm putting in the tag (not sure of that matters). I can't just do heroku create because that's going to create a whole new app. I would just like to push changes to an existing app. Any ideas how I could do what I'm trying to do?
Thanks for any help.
Docker is not running on your old laptop.
The heroku container:push builds and pushes the image as defined in the Dockerfile: this needs the Docker deamon to run.
Related
I am having the EXACT same issue as mentioned here: Can't release pushed docker image in heroku but no answers have seemed to worked.
Goal - I am trying to push a simple image or build from my docker on my laptop to heroku.
I already logged into heroku:
heroku login
I tried using the commands from here to push an existing image: https://devcenter.heroku.com/articles/container-registry-and-runtime#pushing-an-existing-image
>docker tag supportalloy/alloyautomate:latest registry.heroku.com/alloyautomate/app
>docker push registry.heroku.com/alloyautomate/app
Using default tag: latest
The push refers to repository [registry.heroku.com/alloyautomate/app]
e1abb02d73c6: Preparing
f0f8f865ab9e: Preparing
9c3ce5529e99: Preparing
bc918295c02b: Waiting
b1ac1eba9be8: Preparing
2638da3625d5: Pushed
7cc0623bd7a8: Pushed
f1859b30ca6b: Pushed
6a35d52a66fd: Pushed
fbd7d5451c69: Pushed
latest: digest: sha256:3e0ab858e3343XXXXXXXXXXX90c33f9ad5bfdc6a160bcaa7c2d97 size: 6622
So it seemed like as if the image was pushed to heroku but I don't see it anywhere in the dashboard. So I googled some more and apparently I am suppose to release the image after pushing but so far nothing has worked for releasing the image.
I tried:
heroku container:release web --app=alloyautomate
! Expected response to be successful, got 404
but got a 404 error
At this point I gave up and tried:
heroku container:release web -a app
! You do not have access to the app app.
which makes sense because I think you suppose to suppose to state the application name in heroku. However I am so lost as to what to do.
I have pushed a folder to heroku before using heroku cli, but I am trying to learn how to push a docker image.
I figured out my own issue again.
The answer is that I needed to set a git remote on the specific app in question.
heroku git:remote -a your_app_name
after doing this, I tried
heroku container:push web
then
heroku container:release and that worked
this is my first time that i try to make a simple deploy, so the procedure is not still clear.
This is what i have done:
For server i'm using a droplet from Digital Ocean.
I created a simple app in node, make a dockerfile and docker-compose.
If i try to lunch "docker-compose up" in local everything is ok.
Then i pushed the project on github
I enstablished a ssh connection with my remote server, and pulled the project form github into the root folder.
I entered in the project folder and lunched "docker-compose up"
The command worked and everything is builed, but if i visit my IP, nothing is showed.
So, how can i route the traffic into the container builded?
Well, if your containers are running correctly after docker-compose up command then you should be able to access the services with {IP}:{PORT}. How are the logs?
By the way, related with that, it is strongly recommended that you start your containers as services by running docker stack deploy {your-stack-name} so they can run in swarm mode, which is the right way to do it in production environment. More on that here
I am trying to push a Docker image to the Heroku repository (web process), but am getting an authorisation issue (in trying to connect to the Heroku repo). Am new to this area, so appreciate any guidance on how to resolve this matter. Below is a screen grab which shows the error at the bottom. To start, it shows that I have successfully built the Docker image and tagged it to heroku. The directory I am running this in, and where the Dockerfile etc is stored is 'quote-app'. Appreciate any help on this please -
Successfully built 74d28e1cf94a
Successfully tagged registry.heroku.com/quote-app/web:latest
jito76#jito76-VirtualBox:~/quote-app$ docker push registry.heroku.com/quote-app/web
The push refers to repository [registry.heroku.com/quote-app/web]
3dc73b143d23: Preparing
2c8df0ddcfaf: Preparing
c73fe40e801c: Preparing
6e9ea2b471fc: Preparing
485a88bfb7a0: Preparing
11b5066d94a5: Waiting
bd8e6688d36c: Waiting
07cab4339852: Waiting
unauthorized: authentication required
jito76#jito76-VirtualBox:~/quote-app$
Thanks for the suggestions peeps. I did login using the 'heroku container:login' command, and it stated that I had "logged in successfully" when I ran the command. I am running the docker commands from the Ubuntu directory, that the container/app is stored in, instead of running it from home or as 'root' user. Hence, Am wondering whether I have the right Linux user rights to execute the code from there. Otherwise, am out of ideas for now
I was doing trial and error and this sorted out the auth issue, not sure what exactly did the magic:
heroku login
heroku stack:set container -a
heroku container:push worker -a
heroku container:login
heroku container:push worker -a
Remember to enter your Heroku App name after -a.
The application name quote-app does not match the Heroku application name: this happens when creating the Heroku app from the command line (heroku create without additional parameters)
It is better to set the application name explicitly
$ heroku create quote-app
$ docker build -t registry.heroku.com/quote-app/web .
$ docker push registry.heroku.com/quote-app/web
$ heroku container:release web -a quote-app
I have made a quite simple golang server and I need to deploy it to a digitalocean droplet.
I know that there can be issues with cross-building go apps in case they use cgo, so to not to think about it in future I decided to use docker, so my app will be build and run always in same environment.
The first thing I dont get is about developing an app. When I create a Dockerfile I use commands to add files from my project directory into newly created docker image. Then I run the container created from this image. But what if I edit my code? - as I understood I must stop the container, remove an image and then build it again. This is a bit tricky for such a common situation - or am I doing things wrong?
Second one - I have created a docker droplet on a DO: Whats the way to deploy my app?
I have to push my image to any docker repository and pull it on to the droplet?
Or I can upload it directly?
Or I have to scp my source code to droplet and run same process as on my local machine, building image and then runnjng a container?
But what if I edit my code? - as I understood I must stop the container, remove an image and then build it again. This is a bit tricky for such a common situation - or am I doing things wrong?
Don't delete the image just rebuild it. It will be much faster than the first initial build. Also why is it tricky? It's just one or two commands, you can create a bash or .bat script if it gets annoying.
I have created a docker droplet on a DO: Whats the way to deploy my app?
All three options are a possibility. For the second one you would have to set up your VM as a docker-hub repo which might be more than you need. Using docker hub isn't bad. You could also just build the image on your server. I recommend using docker hub for it's ease and having watchtower set up on your server to restart your web app on new image pushes.
Edit: the above advice was for a VM not a docker droplet. I'm not familiar with DO but this article should help:
https://blog.machinebox.io/deploy-machine-box-in-digital-ocean-385265fbeafd
I currently have a locally tested and working web app that consists of 4 docker containers: Java MVC, NodeJS, Flask, and MongoDB. I have 4 Dockerfiles, one for each, and I manage the builds with docker-compose.yml.
However, now I want to push my code to Heroku and I read the documentation at https://devcenter.heroku.com/articles/container-registry-and-runtime. However, it seems very ambigious about how to use docker-compose on the production line. This is what it says on the docs:
"If you’ve created a multi-container application you can use Docker Compose to define your local development environment. Learn how to use Docker Compose for local development."
Can anyone guide me to some actual code of how I can push my project to the Heroku Container using Heroku's CLI?
Just an update on this question since it seems to be getting a lot of traction lately.
There is now an officially supported "Heroku.yml" solution offered by Heroku.
You can now write a .yml file (with a format similar to docker-compose) and Heroku will work out your images. Just follow the link above for details.
Happy Heroku-ing.
The more accurate heroku documentation for what you are looking to do is here:
https://devcenter.heroku.com/articles/container-registry-and-runtime
The above will walk you through setting up the heroku container plugin and logging into the registry. You can even migrate an image to a Dockerfile with the following line in your dockerfile:
FROM "<insert Dockerfile tag here>"
To easily set this up, you will name your Dockerfiles with different suffixes, such as Dockerfile.mongo, Dockerfile.node, Dockerfile.flask, and Dockerfile.javamvc. The suffix tells heroku the dyno name used for your web app. When you need to push all of your containers, you can do so with the following command, which will recursively build all dockerfiles as long as all of them have unique suffixes:
heroku container:push --recursive
As Heroku doesn't read docker-compose files, any environment variable setup/port exposure/etc will need to be migrated to the Dockerfile. Also as I can't find how to do persistent storage/volume mounting with containers on Heroku, I would recommend using a Heroku add-on for your mongo database.
On Heroku, you will see your app running as one dyno per Dockerfile, with each dyno's name as the suffix of each Dockerfile.
UPDATE:
Travis brings up a good point. Make sure to have a CMD statement in your Dockerfile, otherwise heroku will throw an error.
Heroku recently added a step to the process, you will need to run heroku container:release <your dyno name> for each dyno that you want to update.
Yet another update on this question, as I was looking into it and found out that Heroku now officially supports docker-compose.
Please follow this guide: Local Development with Docker Compose
Worth noting that, as Heroku is non-persistent, the guide above recommends you to use official docker images of (redis, postgres, etc.) for local development, but use Heroku's offerings when deploying on it.