Agenda:
- Running default python http server in a container.
- ansible/ansible-container-demo
$ pip2 install --user ansible-container[docker]
We'll do
$ python3 -m http.server 9000
in a container
$ docker run --rm fedora:27 python3 -m http.server 9000
We'll spend the whole time inside directory hello
. That's our project.
$ mkdir hello && cd hello
$ cat container.yml
settings:
conductor:
base: 'fedora:26'
services:
web:
from: 'fedora:26'
command: ['python3', '-m', 'http.server', '--bind', '0.0.0.0', '9000']
Let's build it and run it:
$ ansible-container build
$ ansible-container run
-
Expose port to host:
ports: ["9000:9000"]
-
Enable selecting the dir to serve:
defaults: workdir: "/etc"
working_dir: '{{ workdir }}'
-
I also want to put my files in.
- For that, we need add an Ansible role which will copy them.
Find registry inside openshift deployment:
$ oc login -u system:admin
$ oc get svc --all-namespaces
NAMESPACE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default docker-registry 172.30.1.1 <none> 5000/TCP 13m
$ oc login
$ docker login -u $(oc whoami) -p $(oc whoami -t) 172.30.1.1:5000