-
Notifications
You must be signed in to change notification settings - Fork 0
Docker Troubleshooting
These are instructions for troubleshooting Docker for Windows or Mac. For old file for troubleshooting Docker Toolbox.
- The best command to run containers is
docker compose down -v; docker compose up --build
. Notice the down command first. This just keeps thinks clean. - Run
docker compose down -v
when you're done working on a project. (note: some projects may refresh the database on docker compose down -v) - Some operating systems cause issues if your containers are running when they go to sleep. Try stop containers if you can before your computer goes to sleep (e.g. hit
CTRL C
on terminal running container) - If running Docker Desktop for Mac, make sure that cloud sync is not turned on for the folders where your code lives, cloud sync can cause issues with the link between volumes and the local file system.
- If you you haven't rebuilt the project from scratch in a while, you can do so by deleting all the related images noted in the docker/README.md file.
- We highly recommend cleaning up dangling and old images/containers/volumes from time to time. The commands to do this are below.
-
Container name: called containter_name below
- See docker-compose.yml file. This can be specified there via
containter_name: zzzz
in a service
- See docker-compose.yml file. This can be specified there via
-
Volume name: called volume_name below
- See docker-compose file. The volume name can be specified and then docker adds the folder name to the begining of it for some reason
- Make sure docker has access to the folder your code is in. (See docker > settings > resources > filesharing)
- Find the entrypoint start.sh file and replace the last command with
tail -f /dev/null
, this will keep the container running indefinitely and allow you to connect to the container (see helpful commands below) and test the command within the container so you can troubleshoot what may cause it to not start.
- If you've tried everything below and you just can't get it to work, the problem is sometimes that your VM is running out of memory
- Increase your memory in Docker > settings > resources
- the increased amount required may vary based on the project, but we recommend giving the VM as many resources as you can spare. That said, I don't know the any negative consequences of giving the VM too much.
- Important: deleting your docker machine may cause you to lose data stored in named volumes. It may also cause your images to re-build
- Note: This should only be needed in very difficult issues. If you find yourself following these steps often, then you ought to look into other ways to solve your problem.
- try restarting docker
- make sure docker is started
If you see Temporary failure resolving 'archive.ubuntu.com'
OR E: Failed to fetch http://archive.ubuntu.com
OR any other network error
These errors pop up for several different reasons so hopefully one of the solutions below will work.
- Point DNS server to google
- Go to Docker > settings > resources > network and turn on "Manual DNS configuration"
- Then set the DNS to
8.8.8.8
- Try to re-run the build command, sometimes the servers just let us connect
- Try restarting docker
- Try running the command
dockerCleanAll
found below in helpful commands - Try restarting your computer. Sometimes the networks get messed and just need to be restarted.
- Try again later. Sometimes this is just a mirror online that is temporarily down and you just have to try again later.
- If nothing works, you may need to increase the memory of your docker-machine (see steps above)
If you see Cannot start service [your_service]: driver failed programming external connectivity on endpoint [container_name]
or Bind for 0.0.0.0:8000 failed
- Make sure you run
docker compose down -v;
on all other containers that could still be open
The cause of this for me was that a file I had downloaded didn't have the right permissions set for some reason. I had to delete the file in question and re-download it. You could probably change the owner of the file as well.
These errors probably mean that a folder is not mounting correctly.
- make sure that the folder that your files are in is shared with docker
- Run
docker compose down -v; docker compose up --build
- This will only work if the bower.json or package.json has changed. Docker will see the change and update the packages
- Note: sometimes this doesn't work, so you may have to move on to later steps
- First try to start the container_name container
- Open the Docker Quick Start Terminal
- Navigate to where this code is located on your computer
- Start container_name by running
docker compose up
- If the container doesn't exit (i.e. if the terminal just stops and doesn't let you type)
- Open a new Docker Quickstart Terminal
- Connect to the running container
docker exec -it container_name bash
- Run
npm install
and/orbower install --allow-root
- If the docker container doesn't keep running
- Delete the volume holding your node_modules
- Run
docker volume rm [volume_name]
e.g.docker volume rm foldername_node_modules
- Note: to find your volume name, list all volumes on your machine with the
docker volume ls
- Note: if you get this error
Unable to remove volume, volume still in use:
you may need to rundocker compose down
- Note: to find your volume name, list all volumes on your machine with the
- Run
- Delete the volume holding your bower_components
- See instructions to delete volume for node_modules, just change the [volume name]
- Run
docker compose up --build
- Delete the volume holding your node_modules
You'll sometimes see errors like "No space left on device"
- Clean up all dangling images, containers, and volumes
-
docker rmi $(docker images -a --filter=dangling=true -q)
- Clean up all dangling (unused) docker images
-
docker rm $(docker ps --filter=status=exited --filter=status=created -q)
- Clean up all exited containers
-
docker volume rm $(docker volume ls -q -f dangling=true)
- Clean up all dangling (unused) volumes
- run
docker exec -it [container_name] bash
(e.g.docker exec -it container_name bash
)
- run
docker run -t -i [image_name] bash
(e.g.docker run -t -i image_name bash
)
PHP Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found
-or-
Module build failed: Error: ENOENT: no such file or directory, open '/var/www/html/node_modules/...
- Make sure that you do not have cloud sync turned on for the folder containing the code or one of its parent folders. If you did, turn off cloud sync, or relocate the code to a folder not using cloud sync.
- Restart Docker Desktop and reattempt building by running
docker compose down -v
followed bydocker compose up --build
The following can be added to your .bash_profile file or just used as a reference.
alias dockerCleanImages='docker rmi $(docker images -a --filter=dangling=true -q)'
alias dockerCleanPs='docker rm $(docker ps --filter=status=exited --filter=status=created -q)'
alias dockerCleanVolumes='docker volume rm $(docker volume ls -q -f dangling=true)'
alias dockerCleanAll='dockerCleanPs; dockerCleanImages; dockerCleanVolumes'
alias dockerCleanExited='docker rm -v $(docker ps -a -q -f status=exited)'
dockerConnectPs(){
docker exec -it $1 bash
}
dockerConnectImage(){
docker run --rm -it $1
}
alias dockerUp="docker compose down -v; docker compose up --build"
alias dockerDown="docker compose down -v;"
alias dockerStop="docker compose down -v; docker-machine stop"