Marcin Stożek "Perk"
4Developers 2017
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
Obrazek: http://bit.ly/2drqhTB
Odkrywamy koło na nowo :)
Wiki: Operating system level virtualization
Kernel: Control Groups, Layers, Namespaces
(Linux oraz Windows)
Różne systemy (Windows, Linux) i architektury (32/64 bity)
Obrazki: docker.com/what-docker
Demon o nazwie dockerd -uruchomiony tam, gdzie są uruchomione kontenery.
Aplikacja CLI o nazwie docker - uruchomiona gdziekolwiek, komunikuje się z demonem.
Akcje dostępne dla obrazów:
build, commit, tag, history, load, save...
Źródło: docker.com/what-docker
$ cat Dockerfile
FROM openjdk:8
MAINTAINER perk <@marcinstozek>
ENV ENVIRONMENT=production
COPY app.jar /
ENTRYPOINT ["java", "-jar", "app.jar"]
$ docker build . --tag my-app:1.0.0
Sending build context to Docker daemon 2.56 kB
Step 1 : FROM openjdk:8
---> 96cddf5ae9f1
Step 2 : MAINTAINER perk <@marcinstozek>
---> Using cache
---> 39d368002a6d
Step 3 : ENV ENVIRONMENT production
---> Using cache
---> d9b306b7b8bf
Step 4 : COPY app.jar /
---> 4762e69c1044
Removing intermediate container 18d24885bfac
Step 5 : ENTRYPOINT java -jar app.jar
---> Running in ffeda9429d40
---> 0c96dfd878be
Removing intermediate container ffeda9429d40
Successfully built 0c96dfd878be
$ docker images
my-app 1.0.0 0c96dfd878be 47 seconds ago 640.9 MB
Akcje dostępne dla kontenerów:
run, start, stop, kill, rm, export, pause, diff...
$ docker run --name my-app-container my-app:1.0.0
Hello 4Developers 2017 world!
$ docker ps --all --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}"
CONTAINER ID IMAGE STATUS NAMES
95316485ab6c my-app:1.0.0 Exited (0) 9 seconds ago my-app-container
$ docker logs my-app-container
Hello 4Developers 2017 world!
$ docker inspect my-app-container
[
{
"Id": "95316485ab6c0d7fd67912205ee8654f5ffb8161b266dd5c69e2b3d344490f07",
"Created": "2017-04-03T10:11:42.578268726Z",
(...)
$ docker run -it ubuntu:16.04 /bin/bash
root@24a9ea7f2dba:/# echo Look Ma, I am in the container!
Look Ma, I am in the container!
root@24a9ea7f2dba:/# hostname
24a9ea7f2dba
root@24a9ea7f2dba:/# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02
inet addr:172.17.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
(...)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
(...)
$ docker ps --all --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}"
CONTAINER ID IMAGE STATUS NAMES
24a9ea7f2dba ubuntu:16.04 Up 5 minutes peaceful_torvalds
❗ Uwaga na CI: Do-not-use-docker-in-docker-for-ci
Marcin Stożek "Perk"
@marcinstozek / perk.pl