#013 Docker Containers
Tags: docker, devops, tutorial
Published: 2020-06-15 19:36:20

# Introduction

this is part 13 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.
***
# Download app_013
![app_013](https://dev-to-uploads.s3.amazonaws.com/i/vvdddf48acyxqdwnvfa7.png)

if you follow [part 9](https://dev.to/elkhatibomar/009-dockerfile-113f)

```bash
cd location/DevOpsJourney/
git pull
cd app_013
```
replace location with where you clone the DevOpsJourney repo

if your new go to [part 9](https://dev.to/elkhatibomar/009-dockerfile-113f) and do same steps will download old lecture files and new one.

***

# Build image
```bash
docker image build -t app_013 .
```

![build](https://dev-to-uploads.s3.amazonaws.com/i/xkxojn3x1kj0nsmwmv0v.png)
***

# Containers
first I like to mention that there is no need to docker conatiner you can just put container , docker default option is docker container
![container-tip](https://dev-to-uploads.s3.amazonaws.com/i/uxg9rq3bfdqygmkvkjql.png)

# Let's start

let's run our app

![run-it](https://dev-to-uploads.s3.amazonaws.com/i/1xieciv7xxe7v47px9k6.png)

```bash
docker run -it app_013
```
-it for interactive with docker

i am using terminator on linux , he give me ability to split the terminal , in case you have a normal terminal open new tab , and run
```bash
docker ps
```
you can see our container is running with name silly_mclaren
and it's default name gived by docker to us.

![again](https://dev-to-uploads.s3.amazonaws.com/i/wqpk5opc9274hvzr1x4b.png)

when we enter a input the program the container will shutdown.

to able to see shutdown containers we need
![container_down](https://dev-to-uploads.s3.amazonaws.com/i/i8p8bva4gtibjwidxucs.png)

```bash
docker ps -a
```
as we see it's status is exited

to automatically delete the container after it ends do
![auto_rm](https://dev-to-uploads.s3.amazonaws.com/i/uf3rqa55k5nm373v13wk.png)

```bash
docker run --rm -it app_013
docker ps -a
```

we can see that he auto remove our container

***

# running in background
to run in background we add -d

![back](https://dev-to-uploads.s3.amazonaws.com/i/izrj8g6vkliybbkilk3t.png)

```bash
docker run -d -it app_013
docker ps
```

we can see it's running but in background with name amazing_wu

![logs](https://dev-to-uploads.s3.amazonaws.com/i/lpjfz5odzhbx2wxbj3tn.png)

to see our app output (in case of -d) docker logs name
```bash
docker logs amazing_wu
```
to interact with the container that is running in background
```bash
docker logs -f amazing_wu
```
we use -f to do this

***

# Run another one

let's run another container in background also

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/y541n27wk8zy3o8byxwv.png)

```bash
docker run -d -it app_013
```

to see the resources used by our containers run

```bash
docker logs
```

![show](https://dev-to-uploads.s3.amazonaws.com/i/yi0kamd3g1rb9bddp9wg.png)

to stop a container

```bash
docker stop amazing_wu
```
***

# more about containers
you can do a lot with containers , example we can give a name , not a random one , this is you challange

```bash
docker run --name app_013 -it app_013 
```

more about containers run

```bash
docker container --help
```

or see the [docs!](https://docs.docker.com/engine/reference/commandline/container/)