---
# System prepended metadata

title: Create a docker container
tags: [Docker]

---

# Create a docker container

## 1. git clone

```shell=
git clone https://github.com/yuze1995/dotnet_core_docker_example.git
cd dotnet_core_docker_example
```

## 2. build docker image
```shell=
docker build -t dotnet/docker/test:v1 .
```

## 3. create container and run 
```shell=
docker run --name=dotnet_test --env ASPNETCORE_ENVIRONMENT=Development -d -p 7777:80 dotnet/docker/test:v1

## --name： set container name
## --env： set environment variable
## -p： set port mapping, ex. {host port}:{container port}
## -d： run in background
```
> [docker command](https://www.runoob.com/docker/docker-command-manual.html)
 
## 4. open port in firewall --optional
```shell=
firewall-cmd --permanent --zone=public --add-port=7777/tcp
```




###### tags: `Docker`