Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support to run container using port 8080 and non-root user 100 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -7,4 +7,5 @@ RUN make build
FROM scratch
COPY --from=builder /go/whoami/whoami .
ENTRYPOINT ["/whoami"]
EXPOSE 80
USER 100
EXPOSE 8080
81 changes: 68 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,17 +5,72 @@
Tiny Go webserver that prints os information and HTTP request to output

```console
$ docker run -d -P --name iamfoo containous/whoami
$ docker inspect --format '{{ .NetworkSettings.Ports }}' iamfoo
map[80/tcp:[{0.0.0.0 32769}]]
$ curl "http://0.0.0.0:32769"
Hostname : 6e0030e67d6a
IP : 127.0.0.1
IP : ::1
IP : 172.17.0.27
IP : fe80::42:acff:fe11:1b
GET / HTTP/1.1
Host: 0.0.0.0:32769
User-Agent: curl/7.35.0
Accept: */*
---

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @raufkk , what is the reason of removing the default docker-compose documentation, instead of adding the Kubernetes example?

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: whoami-deployment
spec:
replicas: 1
selector:
matchLabels:
app: whoami
template:
metadata:
labels:
app: whoami
spec:
containers:
- name: whoami-container
image: containous-whoami:latest
securityContext:
runAsUser: 100
ports:
- containerPort: 8080
name: whoami
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: whoami-service
spec:
ports:
- name: http
targetPort: 8080
port: 8080
selector:
app: whoami
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: whoami-ingress
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: whoami.local
http:
paths:
- path: /whoamitest
backend:
serviceName: whoami-service
servicePort: 8080
---
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: whoami
spec:
ingress:
- ports:
- port: 8080
protocol: TCP
podSelector:
matchLabels:
app: whoami
policyTypes:
- Ingress

```
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ var port string
func init() {
flag.StringVar(&cert, "cert", "", "give me a certificate")
flag.StringVar(&key, "key", "", "give me a key")
flag.StringVar(&port, "port", "80", "give me a port number")
flag.StringVar(&port, "port", "8080", "give me a port number")
}

var upgrader = websocket.Upgrader{