Docker Community Forums

Share and learn in the Docker community.

How can i create images that appears with slash on their names?

Hello,

How can i create images that appears with slash on their names shown on my docker desktop images list below?

By building it with a tag that has the slashes in it?

Typicaly the first part is a user or an organization and matches a user or group in the container registry you are going to push your image.

Lets assume you created a user x on dockerhub and a repo called y, then you create an image for it with the tag z, you would build your image like this: docker build -t x/y:z .

Ah so, i need to publish it into hub.

I just need to make it with another name to avoid conflicts… I’m creating a custom image from nodejs, so its name is still node i just need to rename the image, so i thing in add a prefix before slash.

Well as it wont works as i thought, how can i change the image name when build it? I’m building with docker-compose build --no-cache

If you build an image, it is up to you whether you push it to a container registry or not.
You only need to take care of correct naming if you are going to push the image to a repository.

You can either build the images with whatever tags (you can use multiple tags if needed) that comme to mind or just re-tag an existing image with an additional name: docker image tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

Though, what good are images if they are not pushed to a registry?!

I am very new to docker world.

I just used a nodejs image to build my dev enviroment using docker-compose build

version: '3'
services:
  wwjsnode:
    image: node:14-alpine
    environment:
      - HOST=0.0.0.0
    ports:
      - '${PORT:-3333}:3333'
    build:
      context: .
      dockerfile: NODE.dockerfile
    volumes:
      - '.:/code/wwjs'
    networks:
      - wwjs
    depends_on:
      - browserless
      - pgsql
      - redis
  # etc... 

But the builded result has the name node and i need to make its name to be: wwjs/node (or wwjsnode without slash)… Just that. I don’t want to add tag, nothing… is just my dev env stuffs i will use with project docker-compose.yaml

When image and build are used for a service, the image element will set the name for the image that is going to be build. I kept the relevant lines of your compose file to illustrate the required change. Afaik, if you don’t provide a tag yourself, the latest tag will be used.

version: '3'
services:
  wwjsnode:
    image: wwjs/node
    build:
      context: .
      dockerfile: NODE.dockerfile
      ...

When building or re-tagging an image, a tag is the identifer that includes the ${group name}/${repo name}:${tag name}. The ambigous naming convention found in the docs can be irritating for beginners.

1 Like

Thank you. Now I understand! :star_struck: :laughing: :laughing:

Feel free to put it into your own words, it might help someone else finding this thread later :slight_smile: