1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

「LaTeX数式」埋込みアニメーション描画環境 Manimを、Dockerコンテナの中で動かして成功した件(Macbook環境編)

Last updated at Posted at 2020-12-28

#環境

  • OS: macOS Catalina
  • Docker: Docker version 20.10.0, build 7287ab3

###MacbookにDockerをインストールしてmakeする手順は、以下を参照ください。

###作成したMP4ファイル

( Qiitaのこの記事に動画ファイルをアップロードするにあたり、ffmpegコマンドでMP4ファイルをGIFファイルに変換しました。 )

( OpeningManimExample.mp4 )

Opening__ManimExample.gif

( WriteStuff.mp4 )

WriteStuff.gif

###生成したLaTeX埋め込み動画ファイル (MP4ファイル)
#####(docker cpコマンドを使って、Dockerコンテナの中から、Macbookのlocalに、コピーしたファイル)

Terminal
ocean@AfoGuardMacBook-Pro ~ % ls ./files_from_docker                                                                                  
OpeningManimExample.mp4	SquareToCircle.mp4	UpdatersExample.mp4	WarpSquare.mp4		WriteStuff.mp4
ocean@AfoGuardMacBook-Pro ~ %

##( 使ったDockerイメージ )
####jasonkwan/manimdocker pullして使いました。

###Manim Docker Container

This container is based on eulertour/manim, except that it has oh-my-zsh and the Powerlevel10k theme and tmux, so that you can easily run parallel interactive manim renderings in your terminal window. Manim is a Python 3-based animation pipeline written by Grant Sanderson of the 3blue1brown YouTube channel. It is not incredibly well documented, so at some point I may add a tutorial here. For now, here are some barebones instructions on using the Docker container:

Start the Docker container, making sure that you mount the host directory that holds your scene code. For example:

docker run -it --rm -v /host/scene/dir:/scenes jasonkwan/manim:latest

###docker pullでdockerイメージをインストール

Terminal
ocean@AfoGuardMacBook-Pro ~ % cd Desktop 
ocean@AfoGuardMacBook-Pro Desktop % docker pull jasonkwan/manim
Using default tag: latest
latest: Pulling from jasonkwan/manim
22dbe790f715: Pull complete 
0250231711a0: Pull complete 
6fba9447437b: Pull complete 
c2b4d327b352: Pull complete 
270e1baa5299: Pull complete 
8dc8edf0ab44: Pull complete 
86ded05de41b: Pull complete 
1eac5266a8fa: Pull complete 
61b3f1392c29: Pull complete 
491e147d71fe: Pull complete 
5a2ecf94c392: Pull complete 
f6bd76470d98: Pull complete 
d1bd77cc51ee: Pull complete 
226e5689b7df: Pull complete 
e708be840c60: Pull complete 
eeda8d3fc845: Pull complete 
60cd4adb5309: Pull complete 
be438c8e715b: Pull complete 
15f95ecef64c: Pull complete 
20f3c9b0097d: Pull complete 
8bb6eaeaae9d: Pull complete 
d5339ff8345f: Pull complete 
5ce6c44e720b: Pull complete 
Digest: sha256:de6abdf84730b7e5041aad2922563060ee189f8748cf658abf9678b91dbe5548
Status: Downloaded newer image for jasonkwan/manim:latest
docker.io/jasonkwan/manim:latest
ocean@AfoGuardMacBook-Pro Desktop % 

###jasonkwan/manimというDockerイメージが入った。

Terminal
ocean@AfoGuardMacBook-Pro Desktop % docker images
REPOSITORY             TAG       IMAGE ID       CREATED         SIZE
manimcommunity/manim   latest    805ff82b5b12   3 weeks ago     1.01GB
jasonkwan/manim        latest    72bbfbf7c70d   5 months ago    2.77GB
hello-world            latest    bf756fb1ae65   12 months ago   13.3kB
ocean@AfoGuardMacBook-Pro Desktop %

###docker runで起動

Terminal
ocean@AfoGuardMacBook-Pro Desktop % docker run -it  jasonkwan/manim:latest 
[powerlevel10k] fetching gitstatusd .. [ok]                                                                                                                               
 root@7b3c5a153a0a  /                                                                                                                           ✔  ⚡  1  15:41:11 

###起動成功(Dockerコンテナの中に入れた!)

dockerコンテナの中
 root@7b3c5a153a0a  /  pwd                                                                                                                      ✔  ⚡  1  15:41:15 
/
 root@7b3c5a153a0a  /  ls                                                                                                                       ✔  ⚡  2  15:41:44 
bin  boot  dev  etc  home  lib  lib64  manim  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
 root@7b3c5a153a0a  /                                                                                                                           ✔  ⚡  3  15:41:46 
 root@7b3c5a153a0a  /  ls manim                                                                                                                 ✔  ⚡  3  15:41:46 
Dockerfile  README.md           docs             example_scenes.py  logo      manim_docker_diagram.png  perf_scenes.py    setup.cfg  stage_scenes.py
LICENSE     docker-compose.yml  environment.yml  from_3b1b          manim.py  manimlib                  requirements.txt  setup.py   travis
 root@7b3c5a153a0a  /                                                                                                                           ✔  ⚡  4  15:41:58 
 root@7b3c5a153a0a  /  cd manim                                                                                                                 ✔  ⚡  4  15:41:58 
 root@7b3c5a153a0a  /manim   master  ls                                                                                                       ✔  ⚡  5  15:42:02 
Dockerfile  README.md           docs             example_scenes.py  logo      manim_docker_diagram.png  perf_scenes.py    setup.cfg  stage_scenes.py
LICENSE     docker-compose.yml  environment.yml  from_3b1b          manim.py  manimlib                  requirements.txt  setup.py   travis
 root@7b3c5a153a0a  /manim   master                                                                                                           ✔  ⚡  6  15:42:05

####manimコマンドが認識された。

Terminal
 root@7b3c5a153a0a  /manim   master  manim                                                                                                  1 ↵  ⚡  7  15:42:38 
usage: manim [-h] [-p] [-w] [-s] [-l] [-m] [--high_quality] [-g] [-i] [-f]
             [-t] [-q] [-a] [-o FILE_NAME] [-n START_AT_ANIMATION_NUMBER]
             [-r RESOLUTION] [-c COLOR] [--sound] [--leave_progress_bars]
             [--media_dir MEDIA_DIR]
             [--video_dir VIDEO_DIR | --video_output_dir VIDEO_OUTPUT_DIR]
             [--tex_dir TEX_DIR] [--livestream] [--to-twitch]
             [--with-key TWITCH_KEY]
             [file] [scene_names [scene_names ...]]

positional arguments:
  file                  path to file holding the python code for the scene
  scene_names           Name of the Scene class you want to see

optional arguments:
  -h, --help            show this help message and exit
  -p, --preview         Automatically open the saved file once its done
  -w, --write_to_movie  Render the scene as a movie file
  -s, --save_last_frame
                        Save the last frame
  -l, --low_quality     Render at a low quality (for faster rendering)
  -m, --medium_quality  Render at a medium quality
  --high_quality        Render at a high quality
  -g, --save_pngs       Save each frame as a png
  -i, --save_as_gif     Save the video as gif
  -f, --show_file_in_finder
                        Show the output file in finder
  -t, --transparent     Render to a movie file with an alpha channel
  -q, --quiet
  -a, --write_all       Write all the scenes from a file
  -o FILE_NAME, --file_name FILE_NAME
                        Specify the name of the output file, ifit should be
                        different from the scene class name
  -n START_AT_ANIMATION_NUMBER, --start_at_animation_number START_AT_ANIMATION_NUMBER
                        Start rendering not from the first animation, butfrom
                        another, specified by its index. If you passin two
                        comma separated values, e.g. "3,6", it will endthe
                        rendering at the second value
  -r RESOLUTION, --resolution RESOLUTION
                        Resolution, passed as "height,width"
  -c COLOR, --color COLOR
                        Background color
  --sound               Play a success/failure sound
  --leave_progress_bars
                        Leave progress bars displayed in terminal
  --media_dir MEDIA_DIR
                        directory to write media
  --video_dir VIDEO_DIR
                        directory to write file tree for video
  --video_output_dir VIDEO_OUTPUT_DIR
                        directory to write video
  --tex_dir TEX_DIR     directory to write tex
  --livestream          Run in streaming mode
  --to-twitch           Stream to twitch
  --with-key TWITCH_KEY
                        Stream key for twitch
 root@7b3c5a153a0a  /manim   master  
dockerコンテナの中
 root@7b3c5a153a0a  /manim   master  which manim                                                                                           2 ↵  ⚡  11  15:44:22 
/usr/local/bin/manim

####コンテナ内で、manimは、きちんと動く

dockerコンテナの中
 root@7b3c5a153a0a  /manim   master  manim example_scenes.py                                                                                 ✔  ⚡  12  15:44:27 
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
1: Banner
2: ComplexTransformationScene
3: CountInBinaryTo256
4: CountInDecimal
5: CountInTernary
6: CountingScene
7: DiscreteGraphScene
8: ExternallyAnimatedScene
9: FactorialBase
10: GraphScene
11: LinearTransformationScene
12: LogoGenerationTemplate
13: MortyPiCreatureScene
14: MovingCameraScene
15: OpeningManimExample
16: OpeningQuote
17: PatreonEndScreen
18: PatreonThanks
19: PiCreatureScene
20: PowerCounter
21: RearrangeEquation
22: ReconfigurableScene
23: SampleSpaceScene
24: SceneFromVideo
25: SpecialThreeDScene
26: SquareToCircle
27: TODOStub
28: TeacherStudentsScene
29: ThreeDScene
30: UpdatersExample
31: VectorScene
32: WarpSquare
33: WriteStuff
34: ZoomedScene

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 4
Writing "0" to Tex/313b3fca39847d25.tex
Writing "1.0" to Tex/870ea63b346ce782.tex



Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/manimlib/extract_scene.py", line 150, in main
    scene = SceneClass(**scene_kwargs)
  File "/usr/local/lib/python3.7/site-packages/manimlib/scene/scene.py", line 52, in __init__
    self.construct()
  File "/usr/local/lib/python3.7/site-packages/manimlib/once_useful_constructs/counting.py", line 205, in construct
    self.increment()
  File "/usr/local/lib/python3.7/site-packages/manimlib/once_useful_constructs/counting.py", line 102, in increment
    added_anims += self.get_digit_increment_animations()
  File "/usr/local/lib/python3.7/site-packages/manimlib/once_useful_constructs/counting.py", line 141, in get_digit_increment_animations
    self.add_configuration()
  File "/usr/local/lib/python3.7/site-packages/manimlib/once_useful_constructs/counting.py", line 76, in add_configuration
    it.cycle(new_template)
NameError: name 'it' is not defined

###example_scenes.pyのサンプル描画「1」を実行 (成功)

dockerコンテナの中
 root@7b3c5a153a0a  /manim   master ?  python3 -m manim example_scenes.py                                                                    ✔  ⚡  13  15:47:25 
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 1
Writing "\centering This is some \LaTeX" to ./media/Tex/664e80e8d8d98482.tex
Writing "This is some \LaTeX" to ./media/Tex/80ed8d4981768252.tex
Writing "\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}" to ./media/Tex/ebc532caee153e1a.tex
Writing "\centering That was a transform" to ./media/Tex/9fa026c959502cbc.tex                                                                                             
Writing "That was a transform" to ./media/Tex/57295160ffb913ef.tex
Writing "\centering This is a grid" to ./media/Tex/4a7a28127f038c1b.tex                                                                                                   
Writing "This is a grid" to ./media/Tex/0e1800da5f412d6a.tex
Writing "\centering That was a non-linear function \\applied to the grid" to ./media/Tex/ef930e6ad7fb0e63.tex                                                             
Writing "That was a non-linear function \\applied to the grid" to ./media/Tex/03df13f55ef83d17.tex
                                                                                                                                                                          
File ready at /manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4

Played 10 animations
 root@7b3c5a153a0a  /manim   master ? 
  • File ready at /manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4と出力された。

  • lsコマンドで確認すると、確かにこのパスにOpeningManimExample.mp4ファイルが出力されている。

dockerコンテナの中
 root@7b3c5a153a0a  /manim   master ?  ls /manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4                                 ✔  ⚡  14  15:49:20
/manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4
 root@7b3c5a153a0a  /manim   master ?                                                                                                        ✔  ⚡  15  15:51:55 

##Dockerを抜ける

dockerコンテナの中
 root@7b3c5a153a0a  /manim   master ?  exit
ocean@AfoGuardMacBook-Pro ~ %

##別のDockerコンテナを新しく立ち上げる

###- Docker ID: b11252fc4c1e

ここで、最初に立ち上げたのとは別のコンテナをdocker runで立ち上げずに、先ほど立ち上げたコンテナにdocker startで入り直しても良い。

dockerコンテナの中
 root@b11252fc4c1e  /manim   master  hostname                                                                                                ✔  ⚡  11  16:09:11 
b11252fc4c1e
 root@b11252fc4c1e  /manim   master  python3 -m manim example_scenes.py                                                                       ✔  ⚡  9  16:03:19 
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 1
Writing "\centering This is some \LaTeX" to ./media/Tex/664e80e8d8d98482.tex
Writing "This is some \LaTeX" to ./media/Tex/80ed8d4981768252.tex
Writing "\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}" to ./media/Tex/ebc532caee153e1a.tex
Writing "\centering That was a transform" to ./media/Tex/9fa026c959502cbc.tex                                                                                             
Writing "That was a transform" to ./media/Tex/57295160ffb913ef.tex
Writing "\centering This is a grid" to ./media/Tex/4a7a28127f038c1b.tex                                                                                                   
Writing "This is a grid" to ./media/Tex/0e1800da5f412d6a.tex
Writing "\centering That was a non-linear function \\applied to the grid" to ./media/Tex/ef930e6ad7fb0e63.tex                                                             
Writing "That was a non-linear function \\applied to the grid" to ./media/Tex/03df13f55ef83d17.tex
                                                                                                                                                                          
File ready at /manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4

Played 10 animations
 root@b11252fc4c1e  /manim   master  ls /manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4                                   ✔  ⚡  10  16:05:09 
/manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4
 root@b11252fc4c1e  /manim   master                                                                                                          ✔  ⚡  11  16:08:04 
 root@b11252fc4c1e  /manim   master  hostname                                                                                                ✔  ⚡  11  16:09:11 
b11252fc4c1e

#ここで、別のTerminalを立ち上げる
####先ほどのTerminalのなかで起動中のDockerコンテナに、このTerminalから__docker cp__コマンドでアクセスして、ファイルをローカルにcopyする。

Terminal(Macbookのlocal端末)
ocean@AfoGuardMacBook-Pro ~ % docker cp
"docker cp" requires exactly 2 arguments.
See 'docker cp --help'.

Usage:  docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
	docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

Copy files/folders between a container and the local filesystem
ocean@AfoGuardMacBook-Pro ~ % 
ocean@AfoGuardMacBook-Pro ~ % cd Desktop 
ocean@AfoGuardMacBook-Pro Desktop % docker ps -all
CONTAINER ID   IMAGE                    COMMAND          CREATED         STATUS         PORTS     NAMES
b11252fc4c1e   jasonkwan/manim:latest   "/usr/bin/zsh"   8 minutes ago   Up 8 minutes             elastic_shaw
ocean@AfoGuardMacBook-Pro Desktop % mkdir files_from_docker     

####ローカルのDesktop直下に作成した__files_from_dockerというディレクトリに、Dockerコンテナ内のファイルをcopyする。__

  • コピー元 : b11252fc4c1e:/manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4
  • コピー先 : ./files_from_docker

「コピー先」のファイルパス__の先頭にあるb11252fc4c1e__は、__DockerコンテナのID番号__です。

Terminal(Macbookのlocal端末)
ocean@AfoGuardMacBook-Pro Desktop % docker cp b11252fc4c1e:/manim/media/videos/example_scenes/1440p60/OpeningManimExample.mp4 ./files_from_docker
ocean@AfoGuardMacBook-Pro Desktop % ls ./files_from_docker 
OpeningManimExample.mp4
ocean@AfoGuardMacBook-Pro Desktop %

####再びDockerコンテナ内で、Manimのサンプルコードを動かして、MP4ファイルを生成する。

###example_scenes.pyのサンプル描画「3」を実行 (成功)

dockerコンテナの中
 root@b11252fc4c1e  /manim   master  hostname                                                                                                ✔  ⚡  11  16:09:11 
b11252fc4c1e
 root@b11252fc4c1e  /manim   master  python3 -m manim example_scenes.py                                                                      ✔  ⚡  12  16:09:17 
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 3
Writing "+" to ./media/Tex/701bbfb7cb8d210c.tex
Writing "0" to ./media/Tex/0f3ccd5562128687.tex
Writing "." to ./media/Tex/0791945beca35ac3.tex
Writing "\dots" to ./media/Tex/56ff6ce3bda9aed7.tex
Writing "2" to ./media/Tex/3d052336c1e3bf0f.tex
Writing "5" to ./media/Tex/957bc2d10c45e9f8.tex
Animation 0: MoveToTargetSquare:   0%|                                                                                                            | 0/300 [00:00<?, ?it/s]Writing "4" to ./media/Tex/0079e539c2bb727b.tex
Writing "9" to ./media/Tex/fcf5bb509920cd38.tex
Writing "8" to ./media/Tex/d381d5de7709b238.tex
Animation 0: MoveToTargetSquare:   1%|▋                                                                                                   | 2/300 [00:01<03:34,  1.39it/s]Writing "3" to ./media/Tex/56d3dc830a188b52.tex
Animation 0: MoveToTargetSquare:   1%|█▎                                                                                                  | 4/300 [00:02<02:30,  1.97it/s]Writing "7" to ./media/Tex/c2a7e295cf7ba1eb.tex
Animation 0: MoveToTargetSquare:   3%|██▋                                                                                                 | 8/300 [00:02<01:39,  2.92it/s]Writing "6" to ./media/Tex/be2011bd7d40b30b.tex
Animation 0: MoveToTargetSquare:   6%|██████▎                                                                                            | 19/300 [00:04<00:59,  4.70it/s]Writing "1" to ./media/Tex/9f555629e552b431.tex
Animation 0: MoveToTargetSquare:  25%|████████████████████████▊                                                                          | 75/300 [00:09<00:28,  7.94it/s]Writing "-" to ./media/Tex/5ae072d0e0fd537e.tex
                                                                                                                                                                          
File ready at /manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4

Played 2 animations
 root@b11252fc4c1e  /manim   master                                                                                                          ✔  ⚡  13  16:14:25 
 root@b11252fc4c1e  /manim   master  ls /manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4                                       ✔  ⚡  13  16:14:29 
/manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4
 root@b11252fc4c1e  /manim   master                                                                                                          ✔  ⚡  14  16:14:36 

####ローカルのDesktop直下に作成した__files_from_dockerというディレクトリに、Dockerコンテナ内のファイルをcopyする。__

Terminal(Macbookのlocal端末)
ocean@AfoGuardMacBook-Pro Desktop % docker cp b11252fc4c1e:/manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4 ./files_from_docker
ocean@AfoGuardMacBook-Pro Desktop % ls ./files_from_docker                                                                                   
OpeningManimExample.mp4	UpdatersExample.mp4
ocean@AfoGuardMacBook-Pro Desktop % 

####Dockerコンテナ内で、Manimのサンプルコードを動かして、MP4ファイルを生成する。

###example_scenes.pyのサンプル描画「5」を実行 (成功)

dockerコンテナの中
 root@b11252fc4c1e  /manim   master  python3 -m manim example_scenes.py                                                                      ✔  ⚡  14  16:15:27 
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 5
Writing "\centering This is a some text" to ./media/Tex/4475e3a270ecfb06.tex
Writing "This is a some" to ./media/Tex/5c074d030e92c7aa.tex
Writing "text" to ./media/Tex/b0d674e36b79c7de.tex
Writing "\sum_{k=1}^\infty {1 \over k^2} = {\pi^2 \over 6}" to ./media/Tex/a64c7561bee319ce.tex
                                                                                                                                                                          
File ready at /manim/media/videos/example_scenes/1440p60/WriteStuff.mp4

Played 3 animations
 root@b11252fc4c1e  /manim   master  ls /manim/media/videos/example_scenes/1440p60/WriteStuff.mp4                                            ✔  ⚡  15  16:15:50 
/manim/media/videos/example_scenes/1440p60/WriteStuff.mp4
 root@b11252fc4c1e  /manim   master                                                                                                          ✔  ⚡  16  16:16:00 

####ローカルのDesktop直下に作成した__files_from_dockerというディレクトリに、Dockerコンテナ内のファイルをcopyする。__

Terminal(Macbookのlocal端末)
ocean@AfoGuardMacBook-Pro Desktop % docker cp b11252fc4c1e:/manim/media/videos/example_scenes/1440p60/WriteStuff.mp4 ./files_from_docker
ocean@AfoGuardMacBook-Pro Desktop % ls ./files_from_docker                                                                              
OpeningManimExample.mp4	UpdatersExample.mp4	WriteStuff.mp4
ocean@AfoGuardMacBook-Pro Desktop % 

####Dockerコンテナ内で、Manimのサンプルコードを動かして、MP4ファイルを生成する。

###example_scenes.pyのサンプル描画「4」を実行 (成功)

dockerコンテナの中
 root@b11252fc4c1e  /manim   master  python3 -m manim example_scenes.py                                                                      ✔  ⚡  16  16:16:31 
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 4
                                                                                                                                                                          
File ready at /manim/media/videos/example_scenes/1440p60/WarpSquare.mp4

Played 2 animations
 root@b11252fc4c1e  /manim   master  ls /manim/media/videos/example_scenes/1440p60/WarpSquare.mp4                                            ✔  ⚡  17  16:17:11 
/manim/media/videos/example_scenes/1440p60/WarpSquare.mp4
 root@b11252fc4c1e  /manim   master                                                                                                          ✔  ⚡  18  16:17:21 

####ローカルのDesktop直下に作成した__files_from_dockerというディレクトリに、Dockerコンテナ内のファイルをcopyする。__

Terminal(Macbookのlocal端末)
ocean@AfoGuardMacBook-Pro Desktop % docker cp b11252fc4c1e:/manim/media/videos/example_scenes/1440p60/WarpSquare.mp4 ./files_from_docker
ocean@AfoGuardMacBook-Pro Desktop % ls ./files_from_docker                                                                              
OpeningManimExample.mp4	UpdatersExample.mp4	WarpSquare.mp4		WriteStuff.mp4
ocean@AfoGuardMacBook-Pro Desktop % 

####Dockerコンテナ内で、Manimのサンプルコードを動かして、MP4ファイルを生成する。

###example_scenes.pyのサンプル描画「2」を実行 (成功)

dockerコンテナの中
 root@b11252fc4c1e  /manim   master  python3 -m manim example_scenes.py                                                                      ✔  ⚡  18  16:17:50 
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 2
                                                                                                                                                                          
File ready at /manim/media/videos/example_scenes/1440p60/SquareToCircle.mp4

Played 3 animations
 root@b11252fc4c1e  /manim   master  ls /manim/media/videos/example_scenes/1440p60/SquareToCircle.mp4                                        ✔  ⚡  19  16:18:10 
/manim/media/videos/example_scenes/1440p60/SquareToCircle.mp4
 root@b11252fc4c1e  /manim   master  ls /manim/media/videos/example_scenes/1440p60/                                                          ✔  ⚡  20  16:18:20 
OpeningManimExample.mp4  SquareToCircle.mp4  UpdatersExample.mp4  WarpSquare.mp4  WriteStuff.mp4  partial_movie_files
 root@b11252fc4c1e  /manim   master                                                                                                          ✔  ⚡  21  16:18:24 

####ローカルのDesktop直下に作成した__files_from_dockerというディレクトリに、Dockerコンテナ内のファイルをcopyする。__

Terminal(Macbookのlocal端末)
ocean@AfoGuardMacBook-Pro Desktop % docker cp b11252fc4c1e:/manim/media/videos/example_scenes/1440p60/SquareToCircle.mp4 ./files_from_docker
ocean@AfoGuardMacBook-Pro Desktop % ls ./files_from_docker                                                                                  
OpeningManimExample.mp4	SquareToCircle.mp4	UpdatersExample.mp4	WarpSquare.mp4		WriteStuff.mp4
ocean@AfoGuardMacBook-Pro Desktop % 

##Dockerを抜ける

dockerコンテナの中
 root@b11252fc4c1e  /manim   master  exit                                                                                                                                  ✔  ⚡  26  17:22:37 
ocean@AfoGuardMacBook-Pro Desktop % 

Dockerコンテナの一覧を確認

Terminal
ocean@AfoGuardMacBook-Pro Desktop % docker ps -a
CONTAINER ID   IMAGE                    COMMAND          CREATED             STATUS                           PORTS     NAMES
b11252fc4c1e   jasonkwan/manim:latest   "/usr/bin/zsh"   About an hour ago   Exited (0) 7 seconds ago                   elastic_shaw
7b3c5a153a0a   jasonkwan/manim:latest   "/usr/bin/zsh"   2 hours ago         Exited (127) About an hour ago             unruffled_lamarr
5cc6c0aebc5b   jasonkwan/manim:latest   "/usr/bin/zsh"   2 hours ago         Created                                    naughty_lewin
0a7091fb0203   hello-world              "/hello"         2 hours ago         Exited (0) 2 hours ago                     pedantic_mccarthy
ocean@AfoGuardMacBook-Pro Desktop % 

docker start -> docker attachで先ほどのコンテナID: にはいると、ファイルは消去されずに保存されている。

Terminal
ocean@AfoGuardMacBook-Pro Desktop % docker ps -a
CONTAINER ID   IMAGE                    COMMAND          CREATED             STATUS                           PORTS     NAMES
b11252fc4c1e   jasonkwan/manim:latest   "/usr/bin/zsh"   About an hour ago   Exited (0) About an hour ago               elastic_shaw
7b3c5a153a0a   jasonkwan/manim:latest   "/usr/bin/zsh"   2 hours ago         Exited (127) About an hour ago             unruffled_lamarr
5cc6c0aebc5b   jasonkwan/manim:latest   "/usr/bin/zsh"   2 hours ago         Created                                    naughty_lewin
0a7091fb0203   hello-world              "/hello"         2 hours ago         Exited (0) 2 hours ago                     pedantic_mccarthy
ocean@AfoGuardMacBook-Pro Desktop %
Terminal
ocean@AfoGuardMacBook-Pro Desktop % docker start b11252fc4c1e
b11252fc4c1e
ocean@AfoGuardMacBook-Pro Desktop %
Terminal
ocean@AfoGuardMacBook-Pro Desktop % docker attach b11252fc4c1e
 root@b11252fc4c1e  /                                                                                                                                                        ✔  ⚡  22  17:21:51 
dockerコンテナの中
 root@b11252fc4c1e  /  pwd                                                                                                                                                   ✔  ⚡  22  17:22:14 
/
 root@b11252fc4c1e  /  cd manim                                                                                                                                              ✔  ⚡  23  17:22:16 
 root@b11252fc4c1e  /manim   master  ls                                                                                                                                    ✔  ⚡  24  17:22:23 
Dockerfile  README.md  __pycache__         docs             example_scenes.py  logo      manim_docker_diagram.png  media           requirements.txt  setup.py         travis
LICENSE     Tex        docker-compose.yml  environment.yml  from_3b1b          manim.py  manimlib                  perf_scenes.py  setup.cfg         stage_scenes.py  videos
 root@b11252fc4c1e  /manim   master                                                                                                                                        ✔  ⚡  25  17:22:24 
 root@b11252fc4c1e  /manim   master  ls /manim/media/videos/example_scenes/1440p60/                                                                                        ✔  ⚡  25  17:22:25 
OpeningManimExample.mp4  SquareToCircle.mp4  UpdatersExample.mp4  WarpSquare.mp4  WriteStuff.mp4  partial_movie_files
 root@b11252fc4c1e  /manim   master                                                                                                                                        ✔  ⚡  26  17:22:35 
 root@b11252fc4c1e  /manim   master  exit                                                                                                                                  ✔  ⚡  26  17:22:37 
ocean@AfoGuardMacBook-Pro Desktop % 

##不要なDockerコンテナを削除

Terminal
ocean@AfoGuardMacBook-Pro Desktop % docker rm 7b3c5a153a0a 
7b3c5a153a0a
ocean@AfoGuardMacBook-Pro Desktop % docker rm 5cc6c0aebc5b 
5cc6c0aebc5b
ocean@AfoGuardMacBook-Pro Desktop % docker rm 0a7091fb0203
0a7091fb0203
ocean@AfoGuardMacBook-Pro Desktop % docker ps -a           
CONTAINER ID   IMAGE                    COMMAND          CREATED             STATUS                      PORTS     NAMES
b11252fc4c1e   jasonkwan/manim:latest   "/usr/bin/zsh"   About an hour ago   Exited (0) 51 seconds ago             elastic_shaw
ocean@AfoGuardMacBook-Pro Desktop % 

#( 付録 )

###__manimcommunity/manim__というdockerイメージはうまくいかなかった。

Terminal
ocean@AfoGuardMacBook-Pro ~ % docker pull manimcommunity/manim
Using default tag: latest
latest: Pulling from manimcommunity/manim
bb79b6b2107f: Pull complete 
35e30c3f3e2b: Pull complete 
aeb1daf7eb83: Pull complete 
0968495f5be2: Pull complete 
190317f62993: Pull complete 
e571b62be8fa: Pull complete 
f6b688859f37: Pull complete 
2bd57b6566f4: Pull complete 
e3d88af4c804: Pull complete 
030ee3063799: Pull complete 
da4e67e97d56: Pull complete 
2efcf08409e1: Pull complete 
37416809075b: Pull complete 
Digest: sha256:8aca8383336776222e4e433262d38f886049b2bcbfdf6fc22795b7cdec815ef8
Status: Downloaded newer image for manimcommunity/manim:latest
docker.io/manimcommunity/manim:latest
ocean@AfoGuardMacBook-Pro ~ %

####失敗

Terminal
ocean@AfoGuardMacBook-Pro ~ % INPUT_PATH=/path/to/dir/containing/source/code
ocean@AfoGuardMacBook-Pro ~ % OUTPUT_PATH=/path/to/output/
ocean@AfoGuardMacBook-Pro ~ % docker-compose run manim example_scenes.py SquareToCircle -l
ERROR: 
        Can't find a suitable configuration file in this directory or any
        parent. Are you in the right directory?

        Supported filenames: docker-compose.yml, docker-compose.yaml
        
ocean@AfoGuardMacBook-Pro ~ %

####失敗

Terminal
ocean@AfoGuardMacBook-Pro ~ % docker run manim                                   
Unable to find image 'manim:latest' locally
docker: Error response from daemon: pull access denied for manim, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
ocean@AfoGuardMacBook-Pro ~ %

####失敗

Terminal
ocean@AfoGuardMacBook-Pro ~ % sudo docker run manim
Password:
Unable to find image 'manim:latest' locally
docker: Error response from daemon: pull access denied for manim, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
ocean@AfoGuardMacBook-Pro ~ %
Terminal
ocean@AfoGuardMacBook-Pro ~ % ls
28_Fukunari_VG.pptx	Documents		Movies			Pictures		bin			reveal.js
Applications		Downloads		Music			Public			python-type-theory
Desktop			Library			ParlAI			bashrc			python-venv
ocean@AfoGuardMacBook-Pro ~ %
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?