Service notebook has neither an image nor a build context specified. At least one must be provided

Viewed 9671

I want to use jupyter/base-notebook:latest image. Here is my docker-compose.yml:

version: "3.7"

services:
  notebook:
    image: jupyter/base-notebook:latest
    build:
      args:
        - NB_USER=appuser
        - NB_UID=1001
        - NB_GID=101
    ports:
      - "3010:8888"
    volumes:
      - "./notebooks:/home/appuser/work"

When I run docker-compose up, I get this error: Service notebook has neither an image nor a build context specified. At least one must be provided. How can I solve it?

1 Answers

There are 2 options: use an existing image OR tell the docker-compose to build it. If both are specified, then Compose names the built image with the jupyter/base-notebook:latest.

If you want to use the jupyter/base-notebook:latest image as is, remove the build: section from your compose file and keep the image::

version: "3.7"

services:
  notebook:
    image: jupyter/base-notebook:latest
    ports:
      - "3010:8888"
    volumes:
      - "./notebooks:/home/appuser/work"

If you want to build a custom image, give it a name that does not conflict with the official image name(preferably) and provide a build context:

services:
  notebook:
    build:
      context: ./<dir-that-contains-the-dockerfile>
      dockerfile: Dockerfile
      args:
        - NB_USER=appuser
        - NB_UID=1001
        - NB_GID=101
    image: <repo>/<img-name>:<tag>
Related