<commit_before>### Build an image from a Dockerfile

```
docker build -t myimage .
```

this will build a image with tag `myimage:latest`.

### Push an image to remote repo/registry

```
docker tag myimage dtr.example.com/gengwg/myimage
docker push dtr.example.com/gengwg/myimage
```

### Passing multiple environment variable to docker container

```
docker run -e ACCESS_TOKEN="abcdefg" -e ADDR="localhost:8080" -it dtr.example.com/gengwg/myimage
```

Or use env file:

```
docker run --env-file ./myenv.lst -it dtr.example.com/gengwg/myimage
```

where myenv.list contains (remove the quotes):

```
ACCESS_TOKEN=abcdefg
ADDR=localhost:8080
```

### Access localhost of host machine from within container

Looks for different Docker versions, this is implemented differently.

Docker 19, one use `host.docker.internal`; 
Docker 13, one just use `localhost` directly.

### Docker save and load

Use when there is no internet connection from server.

on laptop:

```
$ docker images | grep hello
hello-world                                             latest              fce289e99eb9        22 months ago       1.84kB
$ docker save fce289e99eb9 > hello-world.tar
$ scp hello-world.tar my-server:
```
on server:<commit_msg>forwarding port and listen on public interface<commit_after>### Build an image from a Dockerfile

```
docker build -t myimage .
```

this will build a image with tag `myimage:latest`.

### Push an image to remote repo/registry

```
docker tag myimage dtr.example.com/gengwg/myimage
docker push dtr.example.com/gengwg/myimage
```

### Passing multiple environment variable to docker container

```
docker run -e ACCESS_TOKEN="abcdefg" -e ADDR="0.0.0.0:8080" -p 8080:8080 -it dtr.example.com/gengwg/myimage
```

Or use env file:

```
docker run --env-file ./myenv.lst -p 8080:8080 -it dtr.example.com/gengwg/myimage
```

where myenv.list contains (remove the quotes):

```
ACCESS_TOKEN=abcdefg
ADDR=0.0.0.0:8080
```

### Access localhost of host machine from within container

Looks for different Docker versions, this is implemented differently.

Docker 19, one use `host.docker.internal`; 
Docker 13, one just use `localhost` directly.

### Docker save and load

Use when there is no internet connection from server.

on laptop:

```
$ docker images | grep hello
hello-world                                             latest              fce289e99eb9        22 months ago       1.84kB
$ docker save fce289e99eb9 > hello-world.tar
$ scp hello-world.tar my-server:
```
on server:
{'fraction_non_alphanumeric': 0.10795681727309077, 'fraction_numerical': 0.03278688524590164, 'mean_word_length': 3.306368330464716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '278984', 'n_tokens_mistral': 882, 'n_tokens_neox': 765, 'n_words': 267}