赞
踩
docker run -it ubuntu /bin/bash
docker logs mycontainer
FROM ubuntu
RUN apt-get update && \
apt-get install -y apache2
docker cp /app/myfile.txt mycontainer:/tmp
docker exec mycontainer rm /tmp/myfile.txt
bridge
、host
、none
和 container
。docker run -p 8080:80 myimage
docker search ubuntu
docker stop mycontainer
docker push myusername/myimage
docker inspect myimage
docker image prune
docker run --cpus 0.5 --memory 512m myimage
FROM ubuntu
RUN apt-get update && \
apt-get install -y nginx
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
docker run -v /app/myapp:/opt/myapp myimage
在这个命令中,/app/myapp是主机系统上的本地目录,而/opt/myapp是容器中的目标目录。
FROM ubuntu
RUN apt-get update && \
apt-get install -y nodejs npm && \
ln -s /usr/bin/nodejs /usr/bin/node
COPY app.js /app/
EXPOSE 8080
CMD ["node", "/app/app.js"]
docker run -e MY_VAR=value myimage
docker cp mycontainer:/tmp/myfile.txt /app
docker inspect mycontainer
docker history myimage
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
networks:
- mynet
db:
image: "redis:alpine"
networks:
- mynet
networks:
mynet:
docker commit mycontainer myimage
FROM ubuntu
RUN apt-get update && \
apt-get install -y ssh
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
depends_on:
- db
db:
image: "redis:alpine"
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
networks:
- mynet
db:
image: "redis:alpine"
networks:
- mynet
networks:
mynet:
FROM ubuntu
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
EXPOSE 3306
CMD ["mysqld"]
version: '3' services: db1: image: "mysql:8" environment: - MYSQL_ROOT_PASSWORD=password networks: - mynet db2: image: "mysql:8" environment: - MYSQL_ROOT_PASSWORD=password networks: - mynet networks: mynet:
FROM ubuntu
RUN apt-get update && \
apt-get install -y redis-server
EXPOSE 6379
CMD ["/usr/bin/redis-server"]
version: '3'
services:
cache1:
image: "redis:alpine"
networks:
- mynet
cache2:
image: "redis:alpine"
networks:
- mynet
networks:
mynet:
FROM ubuntu
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
version: '3' services: web1: build: . ports: - "80:80" networks: - mynet web2: build: . ports: - "81:80" networks: - mynet networks: mynet:
FROM ubuntu
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y nginx
EXPOSE 80
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
version: '3' services: web1: build: . ports: - "80:80" networks: - mynet web2: build: . ports: - "81:80" networks: - mynet networks: mynet:
FROM ubuntu
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y openjdk-8-jre-headless
COPY app.jar /app/
EXPOSE 8080
CMD ["java", "-jar", "/app/app.jar"]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。