환경설정

Docker amd64 ubuntu 설정

CodePoetry 2023. 4. 16. 14:50

M1 Mac - (Ubuntu 18.04 docker image) - cross compile & scp - RPI

 

참고로 RPI3와 우분투 도커 이미지 시스템 정보는 다음과 같다.

rpi
Linux raspberrypi 4.19.127-v7+ #1 SMP Sun Dec 19 00:43:20 KST 2021 armv7l GNU/Linux

Docker
Linux d736e208743c 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

[2023/7/30 업데이트] m1에서 docker 생성 시 platform을 설정하지 않으면 aarch64 ubuntu가 만들어진다. 아래와 같이 --platform을 지정하여 amb64 이미지를 만드는 것이 여러모로 편리하다.

Linux c8718d034859 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

 

도커 이미지 설치

M1 MacOS에 리눅스 컨테이너를 올리는 방법은 여기를 참고했다.

https://mangu.tistory.com/186

 

1. 도커 데스크탑 설치

https://www.docker.com/products/docker-desktop/

 

2. dockerfile 작성

FROM --platform=linux/amd64 ubuntu:18.04 이 부분이 굉장히 중요하다

FROM --platform=linux/amd64 ubuntu:18.04
MAINTAINER username <asd@gmail.com>

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ Asia/Seoul
ENV PYTHONIOENCODING UTF-8
ENV LC_CTYPE C.UTF-8

WORKDIR /root

RUN apt-get update && apt-get install -y netcat

RUN apt update --fix-missing
RUN apt install python git curl wget vim zsh python3 python3-pip net-tools sudo gcc -y
RUN python3 -m pip install --upgrade pip

RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting
RUN echo "source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc

RUN git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
RUN echo "source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ~/.zshrc
RUN echo "ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=111'" >> ~/.zshrc

RUN echo "syntax on\\nfiletype indent plugin on\\nlet python_version_2=1\\nlet python_highlight_all=1\\nset tabstop=8\\nset softtabstop=4\\nset autoindent\nset nu">>~/.vimrc

RUN sudo chsh -s $(which zsh)

3. 도커 빌드

docker build -t test:18 -< dockerfile

4. 컨테이너 실행 (pc 재부팅 시 이 과정은 다시 해주어야 한다)

docker run -it --name test test:18
docker start test
docker exec -it test /bin/zsh

 

VS code를 이용해 linux docker 환경에 접속하기

Remote development extension을 통해서 attach to container