can't build dev container
ERROR: failed to solve: process "/bin/sh -c sdkmanager \"system-images;android-${ANDROID_PLATFORM_VERSION};google_apis;x86_64\" \t && avdmanager create avd -n Android${ANDROID_PLATFORM_VERSION} -k \"system-images;android-${ANDROID_PLATFORM_VERSION};google_apis;x86_64\"" did not complete successfully: exit code: 1
[2023-02-11T11:18:19.044Z] Stop (80644 ms): Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-nickveliki/container-features/0.29.0-1676114218379/Dockerfile-with-features -t vsc-flutter-dev-container-a9f261cac1bec1191e0c07ed437c6ab1 --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /home/nickveliki/Downloads/flutter-dev-container/.devcontainer
[2023-02-11T11:18:19.045Z] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-nickveliki/container-features/0.29.0-1676114218379/Dockerfile-with-features -t vsc-flutter-dev-container-a9f261cac1bec1191e0c07ed437c6ab1 --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /home/nickveliki/Downloads/flutter-dev-container/.devcontainer
[2023-02-11T11:18:19.045Z] at pie (/home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js:1916:1698)
[2023-02-11T11:18:19.045Z] at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
[2023-02-11T11:18:19.045Z] at async vF (/home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js:1915:1972)
[2023-02-11T11:18:19.045Z] at async P7 (/home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js:1915:901)
[2023-02-11T11:18:19.045Z] at async Fie (/home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js:1921:2093)
[2023-02-11T11:18:19.046Z] at async Vf (/home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js:1921:3241)
[2023-02-11T11:18:19.046Z] at async eoe (/home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js:2045:17324)
[2023-02-11T11:18:19.046Z] at async Qse (/home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js:2045:17065)
[2023-02-11T11:18:19.050Z] Stop (81097 ms): Run: /snap/code/119/usr/share/code/code --ms-enable-electron-run-as-node /home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/nickveliki/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-ba948632-49f6-4e79-90ef-68673458c5d51676114216665 --workspace-folder /home/nickveliki/Downloads/flutter-dev-container --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/nickveliki/Downloads/flutter-dev-container --id-label devcontainer.config_file=/home/nickveliki/Downloads/flutter-dev-container/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/nickveliki/Downloads/flutter-dev-container/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-02-11T11:18:19.050Z] Exit code 1
[2023-02-11T11:18:19.053Z] Command failed: /snap/code/119/usr/share/code/code --ms-enable-electron-run-as-node /home/nickveliki/.vscode/extensions/ms-vscode-remote.remote-containers-0.275.1/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/nickveliki/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-ba948632-49f6-4e79-90ef-68673458c5d51676114216665 --workspace-folder /home/nickveliki/Downloads/flutter-dev-container --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/nickveliki/Downloads/flutter-dev-container --id-label devcontainer.config_file=/home/nickveliki/Downloads/flutter-dev-container/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/nickveliki/Downloads/flutter-dev-container/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-02-11T11:18:19.054Z] Exit code 1
so I encountered a few problems, found a few solutions so that I can actually get the container to build
New DOCKERFILE
#-------------------------------------------------------------------------------------------------------------
# Flutter Dev Container - Lucas Hilleshein dos Santos.
# Licensed under the MIT License.
# See https://github.com/lucashilles/flutter-dev-container/blob/master/LICENSE for license information.
#-------------------------------------------------------------------------------------------------------------
FROM ubuntu:latest
#Locale
ENV LANG C.UTF-8
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
#
# Install needed packages, setup user anda clean up.
RUN apt update \
&& apt install -y sudo \
&& apt install -y openjdk-11-jdk-headless --no-install-recommends \
&& apt install -y wget curl git xz-utils zip unzip --no-install-recommends
# Clean Up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
# [Optional] Add sudo support for the non-root user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& su $USERNAME \
&& cd $HOME
#
# Android SDK
# https://developer.android.com/studio#downloads
ENV ANDROID_SDK_TOOLS_VERSION=8512546
ENV ANDROID_PLATFORM_VERSION=33
ENV ANDROID_BUILD_TOOLS_VERSION=33.0.0
ENV ANDROID_HOME=/home/vscode/android-sdk-linux
ENV ANDROID_SDK_ROOT="$ANDROID_HOME"
ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/cmdline-tools/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/emulator
#
# Flutter SDK
# https://flutter.dev/docs/development/tools/sdk/releases?tab=linux
ENV FLUTTER_CHANNEL="stable"
ENV FLUTTER_VERSION="3.3.4"
# Make sure to use the needed channel and version for this.
ENV FLUTTER_HOME=/home/vscode/flutter
ENV PATH=${PATH}:${FLUTTER_HOME}/bin
#
# Android SDK
RUN curl -C - --output android-sdk-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip \
&& mkdir -p ${ANDROID_HOME}/ \
&& unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}/cmdline-tools/ \
&& rm android-sdk-tools.zip \
&& yes | sdkmanager --licenses \
&& touch $HOME/.android/repositories.cfg \
&& sdkmanager platform-tools \
&& sdkmanager emulator \
&& sdkmanager "platforms;android-${ANDROID_PLATFORM_VERSION}" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" \
&& sdkmanager --install "cmdline-tools;latest"
# create emulator android
RUN sdkmanager "system-images;android-${ANDROID_PLATFORM_VERSION};google_apis;x86_64"
# breaks on current avdmanager because it can't be run non-interactively, run AFTER setting up container
# RUN avdmanager create avd -n Android${ANDROID_PLATFORM_VERSION} -k "system-images;android-${ANDROID_PLATFORM_VERSION};google_apis;x86_64" -s
#
# Flutter SDK
RUN curl -C - --output flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/${FLUTTER_CHANNEL}/linux/flutter_linux_${FLUTTER_VERSION}-${FLUTTER_CHANNEL}.tar.xz
RUN tar -xf flutter.tar.xz -C /home/vscode/
RUN rm flutter.tar.xz
#RUN echo $PATH
RUN flutter config --android-sdk "${ANDROID_SDK_ROOT}"
RUN yes | flutter doctor --android-licenses
RUN flutter config --no-analytics
# run AFTER setting up dev container, throws an error when run by docker build
# RUN flutter update-packages
new devcontainer.json
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/lucashilles/flutter-dev-container
{
"name": "Flutter",
"dockerFile": "Dockerfile",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dart-code.dart-code",
"dart-code.flutter"
],
// This command create an example project after the container is created.
// creates test project as root, we no like
// "postCreateCommand": "flutter create test_project",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
//"forwardPorts": [],
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}
This solution did work for me
Improved version of @nickveliki -s docker file
- manual actions not required anymore
- flutter, android-sdk and java versions updated to the latest
#-------------------------------------------------------------------------------------------------------------
# Flutter Dev Container - Lucas Hilleshein dos Santos
# Licensed under the MIT License.
# See https://github.com/lucashilles/flutter-dev-container/blob/master/LICENSE for license information.
#-------------------------------------------------------------------------------------------------------------
FROM ubuntu:latest
#Locale
ENV LANG C.UTF-8
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
#
# Install needed packages, setup user anda clean up.
RUN apt update \
&& apt install -y sudo \
&& apt-cache search openjdk \
&& apt install -y openjdk-17-jdk-headless --no-install-recommends \
&& apt install -y wget curl git xz-utils zip unzip --no-install-recommends
# Clean Up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
# [Optional] Add sudo support for the non-root user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& su $USERNAME \
&& cd $HOME
#
# Android SDK
# https://developer.android.com/studio#command-tools - "Command line tools only" section
ENV ANDROID_SDK_TOOLS_VERSION=10406996
ENV ANDROID_PLATFORM_VERSION=33
ENV ANDROID_BUILD_TOOLS_VERSION=33.0.0
ENV ANDROID_HOME=/home/vscode/android-sdk-linux
ENV ANDROID_SDK_ROOT="$ANDROID_HOME"
ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/cmdline-tools/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/emulator
#
# Android SDK
RUN curl -C - --output android-sdk-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip \
&& mkdir -p ${ANDROID_HOME}/ \
&& unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}/cmdline-tools/ \
&& rm android-sdk-tools.zip \
&& yes | sdkmanager --licenses \
&& touch $HOME/.android/repositories.cfg \
&& sdkmanager platform-tools \
&& sdkmanager emulator \
&& sdkmanager "platforms;android-${ANDROID_PLATFORM_VERSION}" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" \
&& sdkmanager --install "cmdline-tools;latest"
# create emulator android
RUN sdkmanager "system-images;android-${ANDROID_PLATFORM_VERSION};google_apis;x86_64"
RUN echo "no" | avdmanager create avd -n Android${ANDROID_PLATFORM_VERSION} -k "system-images;android-${ANDROID_PLATFORM_VERSION};google_apis;x86_64"
#
# Flutter SDK
# https://flutter.dev/docs/development/tools/sdk/releases?tab=linux
ENV FLUTTER_CHANNEL="stable"
ENV FLUTTER_VERSION="3.13.1"
# Make sure to use the needed channel and version for this.
ENV FLUTTER_HOME=/home/vscode/flutter
ENV PATH=${PATH}:${FLUTTER_HOME}/bin
#
# Flutter SDK
RUN curl -C - --output flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/${FLUTTER_CHANNEL}/linux/flutter_linux_${FLUTTER_VERSION}-${FLUTTER_CHANNEL}.tar.xz
RUN tar -xf flutter.tar.xz -C /home/vscode/
RUN rm flutter.tar.xz
RUN flutter config --android-sdk "${ANDROID_SDK_ROOT}"
RUN yes | flutter doctor --android-licenses
RUN flutter config --no-analytics
RUN git config --global --add safe.directory /home/vscode/flutter
RUN flutter update-packages
@Akiyamka and @nickveliki, Thank you for the improvements. It helped me solve my build issues. Wouldn't it be better to create a PR based on your suggestions?
@camcam1773 if you would like to, you have my approval to do it with my solution. I considered this repo abandoned until I saw your and @Akiyamka's comments just now. The project which I wanted this for has also since changed to electron with react-ts