Run Docker image without any steps


#1

Let’s say I have a Docker image which does some work as part of a workflow in which I do not need to run any commands because it is a specialized image created just for the task.

This is what I would like to do:

  qa-notify-slack:
    docker:
      - image: privatedockerregistry.io/deployment_notify_slack:1.0
    environment:
      TARGET_ENV: "qa"

But it fails with the following errors:

* in job 'qa-notify-slack': steps is not a list
* Config file is invalid:
  at jobs: steps: steps is required

I had to add a fake step which you’ll not be happy about but I don’t want to run a command in my container:

  qa-notify-slack:
    docker:
      - image: privatedockerregistry.io/deployment_notify_slack:1.0
    environment:
      TARGET_ENV: "qa"
    steps: # fake step to make CircleCI linter happy
      - setup_remote_docker

In my opinion running a specialized Docker image which does some work during the CI/CD run but doesn’t do anything with the code is a valid use-case. Think about clearing caches, notifying tools like Slack, NewRelic or Sentry about the deployment or other custom commands.


#2

You could just have a step of true, which will be a null operation in this case.


#3

If you mean run: "true" then that is certainly the opposite of what I want because it overwrites the entrypoint.


#4

Ah yes, I did mean that. I see the problem now.

The other option you have is to take the secondary containers you are running now, and run them inside your own installation of Docker Compose in your primary CircleCI build machine. It’s what I do for my functional tests in a microservices app, and it is very flexible. It has the advantage that I can run those tests locally too, and makes things less reliant on the CircleCI way of doing things.


#5

That also isn’t a real solution, I just posted a stripped down example but really I have this in a workflow where I only run these containers if other workflow steps succeed.

Best solution I came up with is to call the entrypoint but that shouldn’t be necessary because it requires some knowledge about how the image was built:

  qa-notify-slack:
    docker:
      - image: privatedockerregistry.io/deployment_notify_slack:1.0
    environment:
      TARGET_ENV: "qa"
    steps:
      - run: /docker-entrypoint.sh

#6

Hi there. I’m a volunteer here, so do please try to remember your manners when asking for help.


#7

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.