docker镜像与容器

docker镜像与容器

docker镜像与容器

镜像与容器

使用dockerfile创建镜像docker build -t fukong99/tinynote:latest .

查看镜像:docker images

更改镜像名称:docker tag tinynote:latest fukong99/tinynote:latest

查看容器:docker ps

生成容器:docker-compose up -d

本地使用docker compose.yml创建容器docker compose.yml文件内指定镜像需修改:image:fukong99/tinynote:latest(镜像的名称)

上传docker hub

openaiassets_2e38e8ee4fcc6517a9c165991d3db6b5_2579861722001415459.png

上传docker hub,使用build: .(build: .会查找镜像没有回自行构建镜像 )
docker-compose.yml

[root@VM-12-5-centos web]# cat docker-compose.yml
services:
  app:
    build: . `.` 这表示当前目录,即 Docker Compose 文件所在的目录,构建一个名为 "app" 的服务
    #image: fukong99/tinynote:latest #使用指定docker hub 镜像格式为 <用户名>/<镜像名>:标签
    working_dir: /app
    ports:
      - 5050:5050
    volumes:
      - ./:/app
    restart: always
    # command: sh -c "tail -f /dev/null"
    command : sh -c "python /app/houtai.py"
[root@VM-12-5-centos web]#
Comment