Friday, May 11, 2018

Dokku app deployment fails with a “main: command not found. access denied”. Its most likely a storage space issue...

If your Dokku app deployment failed with an error similar to this:

/home/dokku/.basher/bash: main: command not found
Access Denied

And you have confirmed that its not some typo in your command or if your remote server is down or repo has been deleted etc... then you most likely have hit this issue due to your remote server going out of space.

You can confirm this by SSH'ing into your remote server and hitting the "df -h" command. Once you confirm it then there are a few things you can do to release some space so you can redeploy.

LET'S DO A DEEP CLEAN!

The following is highly risky as you have to deal with docker directly but if you know what you are doing then it should be OK. (but do these at your own RISK!)

Run:
sudo docker ps

To see the docker containers that are running and check for ones that have exited and therefore are not needed

Run:
sudo docker ps -a -q -f status=exited

To see the containers that are exited. You can delete the images behind this to free space. You will see a list. Remove containers using the container IDs. e.g.

sudo docker rm [0fb0724ae3a7] --> this is the containerID

Now check if you have some free space and try to redeploy.

If you still have no space you can try and delete the docker images as well. This is again very risky in case you are not sure what is happening so please do this at your own risk

Run:
docker images

or Run:
sudo docker images | grep '<none>'

This should show you orphaned images.

Start deleting some images using this command:
sudo docker rmi [afa892371d46]  --> this is the IMAGE ID

Now you should have some space for a deployment.

** If you are using Dokku, then I've noticed that overtime it leaves many Docket containers in a bad state and creates a lot of bloat. At times I go ahead and remove any containers that I feel are invalid containers created by Dokku. The Dokku "app name" is not what necessarily what your Docker container name will be so don't let this confuse you, even if you have no containers that match your dokku app name, the next time push dokku deploy it will spin up a new container for your app. Again - all this is risky do don't attempt unless you are sure.

Hopefully this helps someone. You can read more in these issues raised on Github.
https://github.com/dokku/dokku-mariadb/issues/38
https://github.com/dokku/dokku/issues/120

More dockers commands that are useful:
https://zaiste.net/removing_docker_containers/

Bonus free space tip: Also might help cleaning up for free space on your Linux box. I was using ubuntu 16.04.2 and this article gave some great tips on freeing space: https://www.omgubuntu.co.uk/2016/08/5-ways-free-up-space-on-ubuntu

By running sudo apt-get autoremove I was able to free up close 1 GB!

No comments:

Post a Comment

Fork me on GitHub