Container is just a running process ...
$ docker run ubuntu /bin/echo 'Hello world'
Hello worldContainer will stay only if there is a running process ... you can
start a monitoring process, like bash
docker run -t -i ubuntu /bin/bash
root@af8bae53bdd3:/#or setup a loop
docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
docker logs -f <container-id>TIP: stop and remove all containers in one command
for windows
FOR /f "tokens=*" %i IN ('docker ps -a -q') DO docker stop %i
FOR /f "tokens=*" %i IN ('docker ps -a -q') DO docker rm %ifor linux and Mac
docker stop $(docker ps -qa)
docker rm $(docker ps -qa)- it's just a VM with remote docker access setup for you
- it's for Windows 10 (client os only), not for Servers
- Windows Containers and Linux Container -- all supported
docker run -itd -p 8080:80 nginx
docker run -itd -p 8081:80 nginxλ mkdir docker-training
λ cd docker-training\
λ mkdir php-webapp
λ cd php-webapp\
λ code .In vscode, create file src/index.php and paste in the following code
<html>
<head>
<title>Hello world!</title>
</head>
<body>
<h3>My hostname is <?php echo getenv('HOSTNAME'); ?></h3>
</body>
</html>create Dockerfile
FROM php:7.1-apache
COPY src/ /var/www/html/Build
docker build -t php-webapp:v1 .Ship
docker tag php-webapp:v1 idcfdemo.azurecr.io/php-webapp:v1
docker push idcfdemo.azurecr.io/php-webapp:v1Run
ssh localadmin@vpn-lx.southeastasia.cloudapp.azure.comapiVersion: v1
kind: ReplicationController
metadata:
name: php-webapp
spec:
replicas: 1
template:
metadata:
labels:
app: php-webapp
spec:
containers:
- name: php-webapp
image: idcfdemo.azurecr.io/php-webapp:v1
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: php-webapp
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: php-webappkubectl create -f kube-deploy.yaml
kubectl scale --replicas=5 ReplicationControllers/php-webapp