Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Sep 11, 2020
1 parent 36ae970 commit eedf917
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 53 deletions.
13 changes: 13 additions & 0 deletions docker/create-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,19 @@ docker container cp chronos:/opt/dates.txt .
docker container stop chronos
```

## Docker: Mounting host directory
{id: docker-mounting-host-directory}

```
$ docker run -it --rm -v $(pwd):/opt/ mydocker
# cd /opt
# ls -l
```

The `-v HOST:CONTAINER` will mount the `HOST` directory of the home operating system to the `CONTAINER` directory in the Docker container.


## Exercies 2
{id: exercise-2}

Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions docker/examples/python-4/Dockerfile

This file was deleted.

4 changes: 4 additions & 0 deletions docker/examples/python-curl-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM python:3.8
RUN pip3 install requests
# COPY curl.py .
# ENTRYPOINT ["python3", "curl.py"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions docker/old.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,17 @@ $ docker history mydocker2
```
![](examples/dock/history_mydocker2.out)

## Distribute command-line script and include command
{id: distribute-command-line-script-and-include-command}

![](examples/old-python-5/Dockerfile)


```
$ docker build -t mydocker .
$ docker run --rm mydocker https://code-maven.com/slides
```


63 changes: 13 additions & 50 deletions docker/python.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,44 @@
# Python with Docker
{id: python-with-docker}
{id: python}

## Python CLI in Docker - curl.py
{id: python-cli-in-docker-code}

![](examples/python-3/curl.py)
![](examples/python-curl/curl.py)

## Python CLI in Docker - curl.py
## Python CLI in Docker - Dockerfile
{id: python-cli-in-docker-dockerfile}


![](examples/python-3/Dockerfile)
![](examples/python-curl/Dockerfile)

```
$ docker build -t mydocker .
```
```
docker run --rm mydocker https://httpbin.org/get
$ docker run --rm mydocker https://httpbin.org/get
```

* [https://httpbin.org/](https://httpbin.org/)

{aside}
This is a simple implementation of a curl-like script in Python. Wrapped in a Docker container. Firs build the container and then you can run the script.
{/aside}

## Docker: Mounting host directory
{id: docker-mounting-host-directory}

```
$ docker run -it --rm -v /home/gabor/work/slides/docker/examples/python-3:/opt/ mydocker
$ docker run -it --rm -v c:\Users\Gabor Szabo\work\slides\docker\examples python-3:/opt/ mydocker
# cd /opt
# ls -l
```

The `-v HOST:CONTAINER` will mount the `HOST` directory of the home operating system to the `CONTAINER` directory in the Docker container.

```
# ./curl.py -I https://code-maven.com/slides
```

* You can edit the file on your host system (with your IDE) and run it on the command line of the Docker container.


* A better way to mount the current working directory, at least on Linux and OSX

```
docker run -it --rm -v $(pwd):/opt/ mydocker
```


## Distribute command-line script
{id: distribute-command-line-script}
## Docker: Python Development mode with mounted directory
{id: docker-development-mode-with-mounted-directory}


![](examples/python-4/Dockerfile)
![](examples/python-curl-dev/Dockerfile)

```
$ docker build -t mydocker .
$ docker run --rm mydocker /opt/curl.py https://code-maven.com/slides
```

## Distribute command-line script and include command
{id: distribute-command-line-script-and-include-command}

![](examples/python-5/Dockerfile)


$ docker run --rm -v $(pwd):/opt/ mydocker python /opt/curl.py https://httpbin.org/get
```
$ docker build -t mydocker .

* You can edit the file on your host system (with your IDE) and run it on the command line of the Docker container.

$ docker run --rm mydocker https://code-maven.com/slides
```
* A better way to mount the current working directory, at least on Linux and OSX


## Flask application
Expand Down

0 comments on commit eedf917

Please sign in to comment.