GithubHelp home page GithubHelp logo

dockerfile-lab's Introduction

dockerfile-lab

Lab de Dockerfile do curso Application Development with Red Hat OpenShift

1 - Clone the repository

git clone https://github.com/leomachadorocha/dockerfile-lab.git

2 - Make the shell script executable

$ chmod 755 loveLXC.sh

3 - While still in the project directory, build the Docker image

$ docker build --rm=true -t demorepo/lovelxc .

4 - Note the presence of your new custom Docker image

$ docker images

5 - Run a new container (without passing an environment variable) from your custom image

$ docker run -d --name="my-lovelxc-container" demorepo/lovelxc

6 - Tail the standard output of the container

$ docker logs -f my-lovelxc-container

7 - Review the standard output and press Ctrl+C when you are finished

8 - Delete the existing container and re-instantiate using an environment variable

$ docker rm -f my-lovelxc-container
$ docker run -d --name="my-lovelxc-container" -e NAME="The world" demorepo/lovelxc

9 - Again, tail the standard output

$ docker logs -f my-lovelxc-container

10 - Review the output of this new container and press Ctrl+C when finished

===========================================================================================

Examine Mounted Volume

11 - Execute the docker inspect command and retrieve the path on the host operating system to the container volume

$ docker inspect -f '{{json .Mounts}}' my-lovelxc-container | jq
[
    {
        "Destination": "/var/lovelxc",
        "Driver": "local",
        "Mode": "",
        "Name": "3f249a116633074e34840ddea836f26a570b7ef36bcdb01cdbd22f8f37cf4705",
        "Propagation": "",
        "RW": true,
        "Source": "/var/lib/docker/volumes/3f249a116633074e34840ddea836f26a570b7ef36bcdb01cdbd22f8f37cf4705/_data"
    }
]

OBS:

/var/lovelxc = directory in the container ($ docker exec -it my-lovelxc-container sh)

/var/lib/docker/volumes/ = directory in the host

12 - View the contents of the file written by the script to this external volume on the host operating system

$ cat /var/lib/docker/volumes/3f249a116633074e34840ddea836f26a570b7ef36bcdb01cdbd22f8f37cf4705/_data/super_top_secret_log.log  | more
The world loves linux containers
The world loves linux containers
The world loves linux containers

===========================================================================================

13 - Delete the running container

$ docker rm -f my-lovelxc-container

14 - Delete the image

$ docker rmi demorepo/lovelxc

15 - Delete the busybox base image

$ docker rmi busybox

dockerfile-lab's People

Watchers

James Cloos avatar Leonardo Rocha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.