Resolution
Amazon ECS rejected the container image string that the Update Amazon ECS Service step sent. To fix it, correct that string.
- Find the exact image reference the step built.
- Compare it with the format
registry/repository:tagorregistry/repository@sha256:<64 hex characters>. - Fix what doesn't match, save the process, create a new release, and deploy.
The usual culprits are a protocol prefix, a space or line break, a doubled separator, an uppercase letter in the repository name, or an invalid tag.
If the image text contains #{, is empty, or the package ID comes from a variable or contains a forward slash, you might be seeing a known issue instead. See Known issues.
Symptom
The step fails when it updates the service, and the task log shows:
Amazon.ECS.Model.ClientException: Container.image contains invalid characters.
You may also see one or more of the following:
- The step worked before and fails after you changed the feed, package ID, tag, or an image variable.
- Only some environments, tenants, or channels fail, because each one builds a different image string.
- The same image string pulls fine with
docker pullon your own machine. A client can accept strings that ECS doesn't.
Scope: when this is the right article
Use this article when all of the following are true:
- The failing step is Update Amazon ECS Service.
- The error is exactly
Container.image contains invalid characters. - The image string is visibly malformed, or you haven't yet checked what string the step sent.
This isn't the right article when:
-
The image text contains
#{, is empty, or comes from a package ID variable. This pattern matches a known issue. See Known issues. -
The error mentions
roleArnorwebIdentityToken. Those validation errors point to the AWS account or its authentication settings, not the image. See AWS account variables and the AWS permissions Octopus requires. -
The service updates but tasks don't start. If the image string is well formed but ECS can't find or pull it, you see a pull error on the task in ECS, not this
ClientException. Check that the repository and tag exist, and that the task execution role can pull from the registry.
Cause
When the step runs, Octopus builds the image reference from the feed, the package ID, and the version that the release selected. It then registers a new task definition revision with that string in the container definition. ECS validates the image value as part of that call. If the value isn't a valid image reference, ECS returns Container.image contains invalid characters and no new revision is created.
The error is about the value Octopus sent, not about the image you meant. A tag that exists in your registry can still be rejected if the surrounding string is malformed. These problems cause it most often:
-
Stray characters: a leading or trailing space, a line break, or a protocol prefix such as
https:// -
Broken separators: a doubled
/,:, or., a trailing:or/, or a repository name that starts or ends with a separator - Invalid names: uppercase letters in the repository path, or characters that repository names don't allow
-
Invalid tags or digests: a tag with
+,/, or spaces, a tag longer than 128 characters, or a digest that isn'tsha256:followed by exactly 64 hexadecimal characters
A tag is the version label after the colon, such as 1.2.3. A digest is the unique SHA-256 hash of an image, written after an @ sign instead of a tag.
Diagnosis and fix
1. Capture the exact image string
You need the string ECS received, not the one you intended.
- Open the failed task and select Task log, then turn on Verbose. Find the Update Amazon ECS Service step and note the container name that it reports.
- Open the step in the deployment process. For the failing container, note the feed, the package ID, and whether any of these fields use
#{...}variables. - Open the release and note the version that it selected for that package. A release keeps a snapshot of the process and its variables, so check the release you deployed, not just the current process.
- If any part of the image comes from a variable, print the evaluated variables to the task log by adding the project variables
OctopusPrintVariablesandOctopusPrintEvaluatedVariableswith the valueTrue. Create a new release, deploy with Verbose enabled, and read the evaluated values for the failing step. Turn both variables off afterward. - Assemble the full string in the form
<registry host>/<repository path>:<tag>, then copy it into a plain-text editor with whitespace visible. Look for leading or trailing spaces and line breaks.
To compare against a revision that worked, view the last good task definition in AWS. Open Amazon ECS, select Task definitions, choose the family, and open the last revision that deployed. Or run the following command, replacing the family and revision:
aws ecs describe-task-definition --task-definition my-family:12 --query "taskDefinition.containerDefinitions[].image"
If the step's log shows the task definition that it tried to register, you can read the image value there too. Don't rely on that, as the log might not include it.
2. Test with a literal image reference
- In the step, replace the package, feed, or variable inputs with a literal image reference that you know is valid, such as the full ECR URI and tag copied from the ECR console. Save the process.
- Create a new release, because a deployment of an existing release uses the old snapshot.
- Deploy to one environment.
If the deployment succeeds, the literal string is good and the problem is in how the feed, package ID, tag, or variable builds the string. Continue with steps 3 and 4. If it fails with the same error, the literal string is also invalid. Go to step 3.
3. Compare the string with the ECS image format
The AWS container definition image parameter accepts a Docker image reference. These are the valid forms:
| Form | Example |
|---|---|
| ECR image by tag | 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:1.2.3 |
| ECR image by digest |
123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app@sha256: followed by exactly 64 hexadecimal characters |
| Docker Hub official image |
ubuntu or ubuntu:22.04
|
| Docker Hub image with an organization | amazon/amazon-ecs-agent:latest |
| Image on another registry | quay.io/assemblyline/ubuntu:latest |
The rules behind those forms:
- Repository path. Use lowercase letters and numbers. Separate parts with a period, an underscore, a double underscore, or one or more hyphens. A path component can't start or end with a separator.
- Tag. Use letters, numbers, underscores, periods, and hyphens, up to 128 characters. It can't start with a period or hyphen.
-
Digest. Use
@sha256:followed by exactly 64 hexadecimal characters. ECS supports only SHA-256. -
No tag or digest. ECS treats the image as
latest. - Length. The repository URL and image name together can be up to 255 characters.
4. Look for common mistakes
Compare your string with this table. Each row describes a string that ECS rejects.
| What you see | Example | Fix |
|---|---|---|
| A protocol prefix | https://123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:1.2.3 |
Remove https:// or docker://. An image reference has no protocol. If the prefix comes from the feed URI, use the registry host only. |
| A leading or trailing space or line break |
my-app:1.2.3 followed by a line break |
Remove it from the package ID, tag, or variable value. Check values that were pasted or built from a script output. |
| A space inside the string | my-app: 1.2.3 |
Remove it. A space after the colon is a common typo. |
| A doubled separator |
…amazonaws.com//my-app:1.2.3, my-app::1.2.3, my..app:1.2.3
|
Remove the extra separator. A doubled / often comes from joining a registry that ends in / to a package ID that starts with /. |
| An empty tag or trailing separator |
my-app: or my-app/
|
Provide a tag, or remove the trailing character. An empty version variable produces my-app:. |
| Uppercase in the repository path | …/My-App:1.2.3 |
Rename or reference the repository in lowercase. ECR repository names are lowercase. |
| A tag with an invalid character |
my-app:1.2.3+build5, my-app:feature/login
|
Replace + and / in the tag with - or _. Tags can't contain them. |
| A digest in the wrong form |
my-app@1.2.3, my-app@sha256: with 63 characters, my-app@sha1:…
|
Use @sha256: and exactly 64 hexadecimal characters. A version number isn't a digest. |
| A variable that didn't resolve | #{Project.Image}:1.2.3 |
Go to Known issues. |
A string that repeats the registry host, such as <host>/<host>/my-app:1.2.3, is well formed, so ECS doesn't return this error for it. It fails later, when ECS can't pull the image. If you see it, correct it anyway.
5. Correct the image in the deployment process
- Fix the source of the bad value. This is usually the package ID, the feed URI, the tag or version that the release selected, or the variable that supplies one of them.
- Save the process.
- Create a new release, and select a package version that exists in the registry.
- Deploy to the environment that failed.
Known issues
In May 2026, a known issue stopped the Update Amazon ECS Service step from evaluating some package IDs correctly. It produced this same error for strings that were otherwise correct. If you see either of the following, it's more likely this known issue than a malformed string:
- The image string contains
#{, or part of it is missing, and the package ID comes from a variable. - The package ID contains a forward slash, such as
team/my-app, and the string was valid before an upgrade.
Check GitHub issue 10033 and GitHub issue 10026 for the affected and fixed versions, and the current status.
Information to gather before contacting support
If the literal image reference also fails, or the string looks valid and the problem isn't the known issue, send Octopus Support:
- The task ID (
ServerTasks-###) of a failed deployment, and of a successful one if you have one. - The Octopus Server version, and whether the instance is Octopus Cloud or self-hosted.
- The exact image string from step 1. Remove the AWS account ID and any private repository names that you don't want to share.
- A JSON export of the step from the deployment process.
- The result of the literal image test from step 2.
Verify
- Deploy a new release to the environment that failed.
- In the task log, confirm the Update Amazon ECS Service step completes without the
ClientException. - In the Amazon ECS console, open the service and confirm it now uses a new task definition revision.
- Open that revision, and confirm that the
imagevalue of the container equals the string that you intended. Compare it with the format table in step 3. - If the image comes from variables or per-environment values, deploy to every environment and tenant that uses the step. Each one can build a different string.
- Turn off
OctopusPrintVariablesandOctopusPrintEvaluatedVariablesif you added them.
Related
- Update Amazon ECS Service: how the step selects image versions and creates a new task definition revision.
- Deploy Amazon ECS Service: the guided step that configures the service and containers.
- Debug problems with Octopus variables: how to print evaluated variables to the task log.
-
Variable substitutions: the syntax Octopus uses to evaluate
#{Variable}references. -
AWS container definition
imageparameter: the image formats that ECS accepts. - GitHub issue 10033: the tracked known issue for package IDs in the ECS step.
- GitHub issue 10026: the earlier incident that the known issue relates to.