Prerequisites:
- Docker Desktop (Optional)
- .Net 6
How to setup from thsi repo:
- Clone the repo locally.
- Build and run using Docker profile
- You can access the api on http://localhost:55014/swagger/index.html
Or you can run the app directly from docker:
- Pull the latest image using: docker pull loanburger/product-json-api:latest
- Run the app:
docker run -p <port>:80 loanburger/product-json-api:latest
- You can access the api on http://localhost:/swagger/index.html
How to test:
- The API uses Open API V3 Swagger integration. You can browse and test endpoints here: http://localhost:55014/swagger/index.html
Pushing to Docker Hub Repo:
If you want to push this to your own Docker Hub repository: you can follow these steps:
- You may need log out first
docker logout
then log back in usingdocker login
. - You need to include the namespace for Docker Hub to associate it with your account. The namespace is the same as your Docker Hub account name.
- If your image does not include your account name, you can rename it by tagging it. You can do this using
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
. e.g.docker tag dotnet-mongo-docker YOUR_DOCKERHUB_NAME/product-json-api:tag
. - You can then push your image by running this command:
docker push YOUR_DOCKERHUB_NAME/product-json-api:tag
.
Useful command:
docker build -t "YOUR_DOCKERHUB_NAME/product-json-api:tag" .
- Build the imagedocker push YOUR_DOCKERHUB_NAME/product-json-api:tag
- Publish the image to docker hubdocker exec -it <containername> bash
- allows you to run commands in the containers. See here for more info.docker tag --help
- Help info to tag an image
Helpful Links:
Troubleshooting
- For "requested access to the resource is denied" see this solution