Last active
November 7, 2022 14:03
-
-
Save jordifebrer/efa4dcfec7f8ce8468f1f4ab23b8d8df to your computer and use it in GitHub Desktop.
docker-json-server.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo '{"cities": [{"name": "Barcelona"}, {"name": "Copenhagen"}, {"name": "Edinburgh"}, {"name": "Hanoi"}]}' > /tmp/cities.json | |
docker run -d -p 80:80 -v /tmp/cities.json:/data/db.json clue/json-server | |
# Listing my favourite cities | |
curl http://localhost/cities | |
[ | |
{"name": "Barcelona"}, | |
{"name": "Copenhagen"}, | |
{"name": "Edinburgh"}, | |
{"name": "Hanoi"} | |
] | |
# Listing my favourite cities containing *bar* | |
curl 'http://localhost/cities?name_like=bar' | |
[ | |
{"name": "Barcelona"} | |
] | |
# Full example here: https://devopscell.com/api/rest/json/nodejs/docker/2017/09/27/api-rest-json-server-nodejs-docker.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment