> For the complete documentation index, see [llms.txt](https://jeffgthompsons-organization.gitbook.io/yellow-team/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jeffgthompsons-organization.gitbook.io/yellow-team/training/cloud-guru/introduction-to-kubernetes/running-containers-with-kubernetes.md).

# Running Containers with Kubernetes

**Create an Nginx Pod to Function as a Simple Web Server**

* **Create a Pod running a container with the `nginx` image**
* **Expose port 80 in order to communicate with Nginx once it is running**

**nginx-pod.yml**

```
apiVersion: v1
kind: Pod
metadata:
    name: nginx-pod
spec:
    containers:
    - name: nginx
      image: nginx 
     ports:
     - containerPort: 80      
```

```
kubectl create -f nginx-pod.yml
```

**Run a Redis Instance Using a Kubernetes Pod**

* **Create a Pod running a container with the `redis` image**

**redis-pod.yml**

```
apiVersion: v1
kind: Pod
metadata:
    name: redis-pod
spec:
    containers:
    - name: redis
      image: redis  
```

```
kubectl create -f redis-pod.yml
kubectl get pods
```

<figure><img src="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FxO8oH1DtXPnPgfEwf0Bf%2Fimage.png?alt=media&amp;token=8bd494ce-1ee1-4071-b98e-0e3fd01ca197" alt=""><figcaption></figcaption></figure>

**Check Nginx Container Logs**

* **View the logs from the Nginx container**

```
kubectl get pods -o wide
curl 192.168.194.65
kubectl logs nginx-pod
```

<figure><img src="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FErFMJrrMUn3XDyTSbbDj%2Fimage.png?alt=media&amp;token=37499315-5568-49a8-b727-4d15b7753e0b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FickPETi8NUQUkhzBdCGk%2Fimage.png?alt=media&amp;token=d3133c1b-0128-4624-9878-4c1ddcd5737a" alt=""><figcaption></figcaption></figure>
