<commit_before>#Starting a Container on Azure

Now that we have a virtual machine running with Docker on Azure we can test it out by running a Container. 
We'll use our local Docker client in doing so.

The easiest way to verify that the Docker host is running and functional on Azure is to use [busybox](https://registry.hub.docker.com/_/busybox/) for creating a "Hello World" Container:
```
$  docker run busybox echo hello world
```

>Note: If you're using the VM created using the Azure CLI in Excercise 03 - you will need to add the --tls option right after `docker` 


The output will look something like this
```
    Unable to find image 'busybox:latest' locally
    511136ea3c5a: Pull complete
    df7546f9f060: Pull complete
    ea13149945cb: Pull complete
    4986bf8c1536: Pull complete
    busybox:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
    Status: Downloaded newer image for busybox:latest
    hello world
```

Let's try running another container that might be a bit more useful.

Running the following command will start an [nginx](https://hub.docker.com/_/nginx/) server
```
$ docker run --name machinenginx -P -d nginx
```
The `-d` flag will ensure that the container runs in the background continuously.

Once you've run the named instance and you want to kill it, you can run the `kill`command:

```cli
$ docker kill machinenginx
```

> If you have not named it you can run `docker ps` to get the assigned name or ID and use it to kill it.

When naming a container that name is allocated for that container, to completely remove it run the following:

```cli
$ docker rm machinenginx
```

The nginx image will by default expose port 80 and 443, because of the `EXPOSE` instruction within the image.
The `-P` flag will have Docker assign random ports to the container, so both port 80 and 443 will be exposed externally.

If you want to specify the public ports directly, so you don't get random public ports assigned you need to run it as follows

```cli
$ docker run --name machinenginx -p 49153:80 -p 49154:443 -d nginx
```

The 49153:80 and 49154:443 syntax is specifying the public port mapped to the private port (public:private).


You can verify that the ports have been mapped by running the `docker ps -a` command. The output should look similar to the following:
```
IMAGE               PORTS
nginx:latest        0.0.0.0:49153->80/tcp, 0.0.0.0:49154->443/tcp
busybox:latest
```

To simplify it all, lets use standard ports (80, 443). By just running without specifying ports, it will use the defaults.

```cli
$ docker run --name machinenginx -d nginx
```
<commit_msg>Explicitly setting ports - without it; no ports<commit_after>#Starting a Container on Azure

Now that we have a virtual machine running with Docker on Azure we can test it out by running a Container. 
We'll use our local Docker client in doing so.

The easiest way to verify that the Docker host is running and functional on Azure is to use [busybox](https://registry.hub.docker.com/_/busybox/) for creating a "Hello World" Container:
```
$  docker run busybox echo hello world
```

>Note: If you're using the VM created using the Azure CLI in Excercise 03 - you will need to add the --tls option right after `docker` 


The output will look something like this
```
    Unable to find image 'busybox:latest' locally
    511136ea3c5a: Pull complete
    df7546f9f060: Pull complete
    ea13149945cb: Pull complete
    4986bf8c1536: Pull complete
    busybox:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
    Status: Downloaded newer image for busybox:latest
    hello world
```

Let's try running another container that might be a bit more useful.

Running the following command will start an [nginx](https://hub.docker.com/_/nginx/) server
```
$ docker run --name machinenginx -P -d nginx
```
The `-d` flag will ensure that the container runs in the background continuously.

Once you've run the named instance and you want to kill it, you can run the `kill`command:

```cli
$ docker kill machinenginx
```

> If you have not named it you can run `docker ps` to get the assigned name or ID and use it to kill it.

When naming a container that name is allocated for that container, to completely remove it run the following:

```cli
$ docker rm machinenginx
```

The nginx image will by default expose port 80 and 443, because of the `EXPOSE` instruction within the image.
The `-P` flag will have Docker assign random ports to the container, so both port 80 and 443 will be exposed externally.

If you want to specify the public ports directly, so you don't get random public ports assigned you need to run it as follows

```cli
$ docker run --name machinenginx -p 49153:80 -p 49154:443 -d nginx
```

The 49153:80 and 49154:443 syntax is specifying the public port mapped to the private port (public:private).


You can verify that the ports have been mapped by running the `docker ps -a` command. The output should look similar to the following:
```
IMAGE               PORTS
nginx:latest        0.0.0.0:49153->80/tcp, 0.0.0.0:49154->443/tcp
busybox:latest
```

To simplify it all, lets use standard ports (80, 443). By just running without specifying ports, it will use the defaults.

```cli
$ docker run --name machinenginx -p 80:80 -p 443:443 -d nginx
```

{'fraction_non_alphanumeric': 0.06965718453683442, 'fraction_numerical': 0.03938730853391685, 'mean_word_length': 3.8325991189427313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '917667', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1494, 'n_words': 826}