-
Enable and Disable the diego_docker Feature Flag The diego_docker feature flag governs whether a CF deployment supports Docker containers.
To enable Docker support, run:
cf enable-feature-flag diego_docker
To disable Docker support, run:
cf disable-feature-flag diego_docker
-
Then in first step we should build this docker image
FROM golang:1.10 ENV CGO_ENABLED=0 \ GOOS=linux \ GOARCH=amd64 # Set the Current Working Directory inside the container WORKDIR $GOPATH/src/logemitter # Copy everything from the current directory to the PWD(Present Working Directory) inside the container COPY . . # Download all the dependencies RUN go get -d -v ./... # Install the package RUN go install -v ./... # This container exposes port 8080 to the outside world EXPOSE 8080 # Run the executable CMD ["logemitter"]
-
For building docker image docker image you should run command like this
docker build -t hmanukyan/logemitter:1.2 .
- hmanukyan is docker hub id (should get from docker-hub account username)
- logemitter is repo name (could be any name)
- 1.3 is image name OR tag name (could be any name)
-
In the next step, you mast push docker in your account
Important Notes,
It is mandatory to push, cf not get the image from local docker repositorydocker image push hmanukyan/logemitter:1.2
-
finally we can push the app in cloud foundry
cf push logemitter --docker-image hmanukyan/logemitter:1.2 \ --no-route --no-start --health-check-type process
-
If you interesting how to run docker image in locally then you can look this example
docker container run -d --name APPLICATION_NAME hmanukyan/logemitter:1.2
- You can see container with this
docker ps
command and with flag-a
you can see all containers which is not successfully rundocker ps -a
- You can see container with this
Notes,
for running application which is running in some port you need add -p 8000:8080
docker container run -d --name APPLICATION_NAME -p 8000:8080 hmanukyan/logemitter:1.2