Download presentation
Presentation is loading. Please wait.
1
Container technology, Microservices, and DevOps
Digital Innovation Workshop April 2019 Henrik Bærbak Christensen
2
Henrik Bærbak Christensen
Exercise 0 Create a Dockerfile that only Is based upon ‘henrikbaerbak/jdk8-gradle’ Sets WORKDIR to /root/cave Copies ‘build.gradle’ into that directory Now execute your image like ‘docker run -ti (yourimage) bash’ And validate that the file is in the right place... Henrik Bærbak Christensen
3
Henrik Bærbak Christensen
Exercise 1 Using Docker to containerize the ‘daemon’ Create an image using Dockerfile that Contains the SkyCave case code, expose port 4567, and issue a command to start the daemon (‘gradle daemon –Pcpf=http.cpf’) When ‘docker run’ed will start a daemon using the HTTP protocol exposed on port 4567 Test run your daemon container portmapped to localhost:4567 docker run –d –p 4567:4567 (yourimage) Run your cmd against it from M51 (and/or open browser on localhost:4567/info) Henrik Bærbak Christensen
4
Henrik Bærbak Christensen
Hint As base image you will need a linux with Java 8 and gradle installed You should my image: ‘henrikbaerbak/jdk8-gradle’ as base Do it the simple and ‘incorrect’ way (include the src) Just copy the source code and build.gradle, CPF files, etc. And issue the ‘gradle daemon –Pcpf=(…).cpf’ Will pull dependencies, compile, and then run the daemon Do not oversimplify Just copy ”/cave” project will copy ALSO all derived files (.class files) which is may cause problems… Henrik Bærbak Christensen
5
Henrik Bærbak Christensen
Hint! My own matra for development is take small steps !!! How to climb a 4 meter high wall? Use a vaulting pole? Fast – if you do not break your neck Use a ladder? Slow – but faster than being hospitalized So, use the debugging tips, and grow the dockerfile rather than use ‘big bang integration’... Make the ‘copy source code’ part first, create the image, use ‘docker run –ti (image) bash’ to run a shell inside the container and inspect the file system Add more stuff and repeat Henrik Bærbak Christensen
6
Henrik Bærbak Christensen
Anatomy of an Image State your base image FROM Identify yourself Copy your software WORKDIR set working directory in container COPY (src) (dest) copy from src to dest (src: relative to current dir, dest: rel. to workdir) Configure EXPOSE expose port to the outside Execute CMD state defaults for process to be run Imhotep Henrik Bærbak Christensen
7
Henrik Bærbak Christensen
Hint: Clean up You will soon have 10s of dead containers docker ps –a Shows even dead containers docker rm –f (containername) Kill that dead container Henrik Bærbak Christensen
8
Henrik Bærbak Christensen
Exercise 2 Context No persistent storage is running for the daemon The cpf ‘digiinno-storage.cpf’ configures daemon for storing data in a running memcached instances on localhost:11211 Exercise Run the skycave server using docker container ‘memcached:1.4’ port mapped to on localhost Test Start daemon, dig a room, kill server, test that room did survive server restart… Henrik Bærbak Christensen
9
Henrik Bærbak Christensen
Hint This exercise is much about networking The three approaches: 1) Reuse the host’s network (you can now use ‘localhost’ in CPF) 2) Create a docker network, and use node names in CPF docker run --name (thenodename) 3) Reuse an existing container’s network Use the --network container:(containername) Henrik Bærbak Christensen
10
Henrik Bærbak Christensen
Exercise 3 Create a container using Dockerfile multistage that In step 1 creates a container that will build a deployment unit (Java Fat JAR file) (See hint next slide on how to do that) In step 2 creates a container that contains the fat jar and will start it when ‘docker run’ed Again, HTTP protocol on port 4567 Henrik Bærbak Christensen
11
Henrik Bærbak Christensen
Hint Gradle supports creating ‘fat jar’. Insert the following into your ‘build.gradle’ The CMD line now has to obey ”java –jar” syntax: java -jar cave.jar whatevercpf.cpf Henrik Bærbak Christensen
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.