Skip to content

Instantly share code, notes, and snippets.

@jordifebrer
Last active November 7, 2022 14:03
Show Gist options
  • Save jordifebrer/efa4dcfec7f8ce8468f1f4ab23b8d8df to your computer and use it in GitHub Desktop.
Save jordifebrer/efa4dcfec7f8ce8468f1f4ab23b8d8df to your computer and use it in GitHub Desktop.
docker-json-server.sh
#!/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