Docker Troubleshooting - ProjectSidewalk/SidewalkWebpage GitHub Wiki

Here are some common problems we've encountered while setting up the dev environment along with potential solutions. We've ordered this list roughly based on when you might observe the problem in the setup process.

You can always ask questions in Slack #interns. We are here to help!

First, here's a table that you'll reference when setting up your dev env

City ID Database User
seattle-wa sidewalk_seattle
columbus-oh sidewalk_columbus
cdmx sidewalk_cdmx
spgg sidewalk_spgg
pittsburgh-pa sidewalk_pittsburgh
newberg-or sidewalk_newberg
washington-dc sidewalk
chicago-il sidewalk_chicago
amsterdam sidewalk_amsterdam
la-piedad sidewalk_la_piedad
oradell-nj sidewalk_oradell
validation-study sidewalk_validation
zurich sidewalk_zurich
taipei sidewalk_taipei
new-taipei-tw sidewalk_new_taipei
keelung-tw sidewalk_keelung
auckland sidewalk_auckland
cuenca sidewalk_cuenca
crowdstudy sidewalk_crowdstudy
burnaby sidewalk_burnaby
teaneck-nj sidewalk_teaneck
walla-walla-wa sidewalk_walla_walla
st-louis-mo sidewalk_st_louis
la-ca sidewalk_la
mendota-il sidewalk_mendota

could not execute query: ERROR: schema "public" already exists

If you see an error like:

pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 9; 2615 2200 SCHEMA public postgres
pg_restore: error: could not execute query: ERROR:  schema "public" already exists
Command was: CREATE SCHEMA public;

This is actually the one error that you can simply ignore! :) It doesn't have any effect.

Execution exception: NoSuchElementException: None.get

If you see an error like:

Execution exception[NoSuchElementException: None.get](/ProjectSidewalk/SidewalkWebpage/wiki/NoSuchElementException:-None.get)

This is most likely because the data from the database is missing and you'd need to import the sql dump. The schema import that's a part of init script only sets the schema and does not import the data.

sh: 1: grunt: not found

If you see an error like:

sh: 1: grunt: not found

This is a known problem (#1517). You can fix it by running npm install grunt from inside the Docker shell.

Running "make import-dump" fails:

If you run make import-dump db=sidewalk_seattle (or similar) and you see errors like this:

could not execute query: ERROR role "sidewalk_seattle" does not exist
could not execute query: ERROR role "saugstad" does not exist

or like this:

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 9; 2615 189957 SCHEMA sidewalk sidewalk_spgg
pg_restore: [archiver (db)] could not execute query: ERROR:  role "sidewalk_spgg" does not exist

then run the following line of code for each role that does not exist:

docker exec -it projectsidewalk-db psql -c "CREATE ROLE <missing-role> SUPERUSER LOGIN ENCRYPTED PASSWORD 'sidewalk';" -U postgres -d sidewalk

For example, to add the role saugstad, you would type:

docker exec -it projectsidewalk-db psql -c "CREATE ROLE saugstad SUPERUSER LOGIN ENCRYPTED PASSWORD 'sidewalk';" -U postgres -d sidewalk

sh: 1: /opt/import-dump.sh: not found

If you see an error like one of these:

sh: 1: /opt/init.sh: not found
sh: 1: /opt/import-users.sh: not found
sh: 1: /opt/import-dump.sh: not found

This is a known problem (#1527). The issue is your files somehow have Windows style line endings, which breaks the shell scripts. If you are on Linux or Windows, you can fix it by running the following lines from outside the Docker shell:

sed -i "s/\r//g" db/init.sh
sed -i "s/\r//g" db/import-users.sh
sed -i "s/\r//g" db/import-dump.sh

If you are on Mac then you will want to run this instead:

ex -bsc '%!awk "{sub(/\r/,\"\")}1"' -cx db/init.sh
ex -bsc '%!awk "{sub(/\r/,\"\")}1"' -cx db/import-users.sh
ex -bsc '%!awk "{sub(/\r/,\"\")}1"' -cx db/import-dump.sh

You will then want to run docker exec -it projectsidewalk-db sh -c "/opt/init.sh" manually before running your make import-dump command again.

For Windows: If you continue to get this error, run the following lines outside the Docker shell:

(Get-Content -Raw "db\init.sh").Endswith("`r`n")
(Get-Content -Raw "db\import-users.sh").Endswith("`r`n")
(Get-Content -Raw "db\import-dump.sh").Endswith("`r`n")

Which should all return False. If they return False and you still receive the error, run the following lines:

docker ps -a
docker stop CONTAINER_ID
docker rm CONTAINER_ID
docker images
docker rmi IMAGE_ID (Make sure to do the ID of projectsidewalk/web)
docker rmi IMAGE_ID (Make sure to do the ID of projectsidewalk/db)

And then run the make dev command again.

If they return 'True' and you still receive the error, then the previous sed commands did not convert your line endings from Windows style to Unix style, so you should run:

(Get-Content -Raw "db\init.sh").Replace("`r`n","`n") | Set-Content "db\init.sh" -Force -NoNewLine
(Get-Content -Raw "db\import-dump.sh").Replace("`r`n","`n") | Set-Content "db\import-users.sh" -Force -NoNewLine
(Get-Content -Raw "db\import-dump.sh").Replace("`r`n","`n") | Set-Content "db\import-dump.sh" -Force -NoNewLine

Which should fix the line endings in the case that the sed commands did not. Now run:

(Get-Content -Raw "db\init.sh").Endswith("`r`n")
(Get-Content -Raw "db\import-users.sh").Endswith("`r`n")
(Get-Content -Raw "db\import-dump.sh").Endswith("`r`n")

And make sure these are all False and continue as described above.

FileNotFoundException: google_maps_api_key.txt (No Such file or directory)

If you execute npm start but run into this error:

[info] play - Application started (Dev)
[error] application -

! @7h87h0af1 - Internal server error, for (GET) [/] ->

play.api.Application$$anon$1: Execution exception[FileNotFoundException: google_maps_api_key.txt (No such file or directory)](/ProjectSidewalk/SidewalkWebpage/wiki/FileNotFoundException:-google_maps_api_key.txt-(No-such-file-or-directory))
        at play.api.Application$class.handleError(Application.scala:296) ~[play_2.10-2.3.8.jar:2.3.8]
        at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.10-2.3.8.jar:2.3.8]
        ...

Make sure you put the Google Maps API key (received from Mikey) into the root directory of your project with the file named exactly google_maps_api_key.txt.

The "make" command is just not working

If it seems like commands that you run using make are just not working, first try reinstalling make. If the issue persists, one workaround has been to look at the Makefile and manually run each command that make is an alias for whenever you need to run something. For example, if you wanted to run make ssh target=web, you would instead run docker exec -it projectsidewalk-web /bin/bash (you can see where the comes from by looking at the Makefile).

Issues connecting to the database

If you are having trouble connecting to the database, one potential issue might be that your docker container for the database might not have the configs set correctly for listening addresses. ssh into the db container and edit the /var/lib/postgresql/data/postgresql.conf file, setting listen_addresses = '*'.

gpg: keyserver receive failed: Server indicated a failure

If you see an error like this on Windows:

gpg: keyserver receive failed: Server indicated a failure

your system is treating this warning as a fatal error and is not completing the build. To fix this, add this line to the Dockerfile at line 2:

ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1

ERROR: Cannot create container for service web: Conflict.

After restarting laptop, you run > make dev but receive an error like this:

> make dev
projectsidewalk-db is up-to-date
Starting projectsidewalk-db ... done
ERROR: Cannot create container for service web: Conflict. The container name "/projectsidewalk-web" is already in use by container "abeedfd010f3bbf9e03d9725b69ab9560b796e9b7e48bef8ff656243fb40a494". You have to remove (or rename) that container to be able to reuse that name.
make: *** [docker-run] Error 1

What probably happened is that your computer was not shut down correctly, so the web container was not closed correctly. To fix, you can just remove that docker container: docker container rm /projectsidewalk-web.

Errors After Computer Was Shut Off With SidewalkWebpage running.

If you are using WSL with Windows, trying running wsl --shutdown in the command prompt. Docker should ask if you want to restart WSL. Click restart. Otherwise, just restart Docker manually and connect again to the WSL Distribution.

ERROR: Docker-Compose Command Failed On Mac

If you encounter an error with the Docker-Compose command on Mac, you may need to recreate the symlink.

  1. Review the documentation - (https://docs.docker.com/compose/install/) - in the installation scenarios to create a new symlink.
  2. Recreate the symlink using the following commands found in the documentation:
    sudo rm /usr/local/bin/docker-compose`
    sudo ln -s /Applications/Docker.app/Contents/Resources/cli-plugins/docker-compose /usr/local/bin/docker-compose`
    
    Note: This is a temporary solution.