2015-05-01 05:16:59 +00:00
## Running your first containers in Kubernetes
Ok, you've run one of the [getting started guides ](../docs/getting-started-guides/ ) and you have
successfully turned up a Kubernetes cluster. Now what? This guide will help you get oriented
to Kubernetes and running your first containers on the cluster.
### Running a container (simple version)
2015-05-08 01:08:27 +00:00
From this point onwards, it is assumed that ```kubectl``` is on your path from one of the getting started guides.
2015-05-01 05:16:59 +00:00
2015-05-08 01:08:27 +00:00
The `kubectl` line below spins up two containers running
2015-05-01 05:16:59 +00:00
[Nginx ](http://nginx.org/en/ ) running on port 80:
```bash
kubectl run-container my-nginx --image=nginx --replicas=2 --port=80
```
Once the pods are created, you can list them to see what is up and running:
2015-05-08 01:08:27 +00:00
```bash
2015-05-01 05:16:59 +00:00
kubectl get pods
```
2015-05-08 01:08:27 +00:00
You can also see the replication controller that was created:
```bash
kubectl get rc
```
2015-05-01 05:16:59 +00:00
2015-05-08 01:08:27 +00:00
To stop the two replicated containers, stop the replication controller:
2015-05-01 05:16:59 +00:00
```bash
kubectl stop rc my-nginx
```
### Exposing your pods to the internet.
On some platforms (for example Google Compute Engine) the kubectl command can integrate with your cloud provider to add a public IP address for the pods,
to do this run:
```bash
2015-05-08 01:08:27 +00:00
kubectl expose rc my-nginx --port=80 --create-external-load-balancer
2015-05-01 05:16:59 +00:00
```
This should print the service that has been created, and map an external IP address to the service.
### Next: Configuration files
Most people will eventually want to use declarative configuration files for creating/modifying their applications. A [simplified introduction ](simple-yaml.md )
2015-05-08 01:08:27 +00:00
is given in a different document.
2015-05-14 22:12:45 +00:00
[![Analytics ](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/simple-nginx.md?pixel )]()